Im Moment lerne ich OpenShift: hier schreibe ich Zeugs auf, das grad spannend ist und ich immer wieder vergesse.


OpenShift Kleinzeugs

create and switch projects

oc new-project thespark
oc projects
oc project thespark
oc delete project thespark

rollback to latest successful deployment

oc rollout undo dc/hallospark
re-enable triggers:  
oc set triggers --auto dc/hallospark

expose applications

oc expose dc/hallogo --port=8080 (generates a service from deployment configuration)
oc expose svc/hallogo (generares a route from service)

list, describe and delete all resources with a label:

oc get all --selector app=hallospark -o yaml
oc describe all --selector app=hallospark
oc delete all --selector app=hallospark 
oc delete pvc --all 

get rid of evicted pods: (as a cluster admin)

oc get pod --all-namespaces  | grep Evicted
oc get pod --all-namespaces  | awk '{if ($4=="Evicted") print "oc delete pod " $2 " -n " $1;}' | sh 

describe etc. resource types, print to yaml

oc describe bc
oc describe dc
oc get secret gitlab-hallospark -o yaml
oc get user
oc get nodes


oc get templates -n openshift 
oc describe template postgresql-persistent -n openshift
oc get template jenkins-pipeline-example -n openshift -o yaml
oc export all --as-template=javapg


oc adm prune builds --confirm etc. 

admin etc.

minishift addons apply admin-user
oc login -u admin (admin)

normal: (on first master)
oc login -u system:admin
oc adm policy add-cluster-role-to-user cluster-admin rschumm

allow root user etc: 
oc adm policy add-scc-to-user anyuid -z default -n myproject --as system:admin

s2i maven “binary workflow”

mvn package fabric8:resource fabric8:build fabric8:deploy

s2i “source workflow” for different languages:

oc new-app fabric8/s2i-java~
oc new-app fabric8/s2i-java~ --source-secret='gitlab-hallospark'
oc new-app openshift/php~
oc new-app openshift/dotnet~

Doku for different languages.

apply a resource

oc apply -f src/main/fabric8/pipeline_bc.yml 

minishift, eclipse che addon etc.

minishift start --cpus 3 --memory 6GB
minishift addons apply che
minishift addons remove che
minishift addons list
minishift update 

Zugriff von Aussen auf die Datenbank etc. (Routes in OpenShift sind nur für HTTP):

rschumm@kassandra:~/git/schufi$ oc port-forward postgresql-1-6pkns 15432:5432

oder noch direkter:

oc exec postgresql-1-nhvs5 -- psql -d explic -c "select experiment from video"

kubernetes dashboard UI

kubectl proxy 

Openshift Multi-Stage-Deployment

Einfachstes Blueprint für Multi-Stage Deployment mit Jenkins-Build-Pipeline

tag manuell:

oc tag sparkpipe/hallospark:latest sparkpipe/hallospark:prod

Deploy von Images aus anderem Namespace:

Service account default will need image pull authority to deploy images from sparkpipe. You can grant authority with the command:

oc policy add-role-to-user system:image-puller system:serviceaccount:sparkpipe-prod:default -n sparkpipe


try {
    //node('maven') {
    node {
        stage('deploy to dev'){
            openshiftBuild(buildConfig: 'hallospark', showBuildLogs: 'true')
        //stage ('deploy'){
        //    openshiftDeploy(deploymentConfig: 'hallospark')
        stage("approve the deployment") {
            input message: "Test deployment: Isch guät?", id: "approval"
        stage("deploy prod"){
            openshift.withCluster() { 
                openshift.tag("sparkpipe/hallospark:latest", "sparkpipe/hallospark:prod")
} catch (err) {
   echo "in catch block"
   echo "Caught: ${err}"
   currentBuild.result = 'FAILURE'
   throw err

zurück zum Seitenanfang