Openshift

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

OpenShift

OpenShift Kleinzeugs

create and switch projects

oc new-project thespark
oc projects
oc project thespark

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 

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

templates

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

registry

oc adm prune builds --confirm etc. 

s2i maven “binary workflow”

mvn package fabric8:resource fabric8:build fabric8:deploy

s2i “source workflow” for different languages:

oc new-app fabric8/s2i-java~https://github.com/rschumm/hallospark.git
oc new-app fabric8/s2i-java~https://gitlab.com/rschumm/hallospark.git --source-secret='gitlab-hallospark'
oc new-app openshift/php~https://github.com/rschumm/hallophp.git
oc new-app openshift/dotnet~https://github.com/rschumm/hallodotnet.git

apply a resource

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

minishift, eclipse che addon etc.

minishift addons apply 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

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

Jenkinsfile

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