EX288 Merge Flashcards
<p>Create image stream</p>
<p>oc import-image stream-name --from URL/${USER}/image-name --confirm</p>
<p>Get OCP internal registry URL</p>
<p>oc get route -n openshift-image-registry</p>
<p>Enable access to internal registry</p>
<p>oc patch config.imageregistry cluster -n openshift-image-registry --type merge -p '{"spec":{"defaultRoute":true}}'</p>
<p>Create webhook</p>
<p>oc set triggers bc/name --from-gitlab</p>
<p>Mount cm into deployment</p>
<p>oc set env deployment/my-deployment-name --from configmap/mycm</p>
<p>Create secrets for OCP to access external registry using username & password</p>
<p>oc create secret docker-registry quayio<br></br>--docker-server=$SERVER<br></br>--docker-username=$USERNAME<br></br>--docker-password=$PASSWORD</p>
<p>Link secrets to access external registry</p>
<p>oc secret link builder credential-name --for=pull<br></br>oc secret link default credential-name --for=pull</p>
<p>oc secrets link deployer quayio --for=pull</p>
<p>Set a command as post commit build hook</p>
<p>oc set build-hook bc/name --post-commit --command -- bundle exec rake test --verbose</p>
<p>Set a post commit build hook using the shell approach</p>
<p>oc set build-hook bc/name --post-commit --script="curl http://api.com/user/${USER}"</p>
<p>How do you check if credentials have been added properly for accessing external registry?</p>
<p>oc describe serviceaccount default</p>
<p>Determine which SCC permissions are required for a pod to run</p>
<p>oc get pod podname -o yaml | oc adm policy scc-subject-review -f -</p>
<p>Create a service account</p>
<p>oc create sa nginx-sa</p>
<p>Connect the service accountnginx-sato the SCCanyuid:</p>
<p>oc adm policy add-scc-to-user anyuid -z nginx-sa</p>
<p>Bind the service accountnginx-sato the pod orsccnginxdeployment to allow it to run with its new permissions</p>
<p>oc set sa deploy podname nginx-sa</p>
<p>List of steps to resolve nginx CrashLoopBackoff</p>
<p></p>
<ul> <li>oc get pod podname -o yaml | oc adm policy scc-subject-review -f -</li> <li>oc create sa nginx-sa</li> <li>oc adm policy add-scc-to-user anyuid -z nginx-sa</li> <li>oc set sa deploy sccnginx nginx-sa</li></ul>
<p>Kubernetes main resource types</p>
<p>POD (po)<br></br>Persistent Volumes (pv)<br></br>Persistent Volume Claims (pvc)<br></br>Build Config (bc)<br></br>Deployment / deployment Confg (dc)<br></br>Services (svc)<br></br>Config Maps (cm)<br></br>Secrets</p>
<p>Login to OCP cluster using CLI</p>
<p>oc login -u user1 -p passwd URL</p>
<p>Forward port to mysql server</p>
<p>oc port-forward mysql 3306:3306</p>
<p>Deploy mysql using template</p>
<p>oc new-app <br></br> --template=mysql-persistent <br></br> -p MYSQL_USER=user1 <br></br><br></br>-p MYSQL_PASSWORD=mypa55 <br></br><br></br>-p MYSQL_DATABASE=testdb <br></br><br></br> -p MYSQL_ROOT_PASSWORD=r00tpa55 <br></br><br></br>-p VOLUME_CAPACITY=10Gi</p>
<p>Deploy mysql using image from registry</p>
<p>oc new-app --image=myregistry.com/mycompany/myapp --name=myapp</p>
<p>Deploy app using github url</p>
<p>oc new-app https://github.com/openshift/ruby-hello-world --name=ruby-hello</p>
<p>Deploy mysql using mysql image</p>
<p>oc new-app mysql MYSQL_USER=user MYSQL_PASSWORD=pass MYSQL_DATABASE=testdb -l db=mysql</p>
<p>Get list of pv</p>
<p>oc get pv</p>
<p>Create pv</p>
<p>oc create -f pvc.yaml</p>
<p>get certain resources</p>
<p>oc get RESOURCE_TYPE RESOURCE_NAME</p>
<p>Show detailed of the resource</p>
<p>oc describe resource_type resource_name</p>
<p>oc create</p>
<p>oc create</p>
<p>edit resource</p>
<p>oc edit deploymentconfig/parksmap-katacoda</p>
<p>Delete resource</p>
<p>oc delete RESOURCE_TYPE name</p>
<p>Search by label</p>
<p>oc get svc,deployments -l app=nexus</p>
<p>Create a route</p>
<p>oc expose svc quotedb --name quote<br></br><br></br>oc expose object_type object_name</p>
<p>Restart an OCP build</p>
<p>oc start-build myapp</p>
<p>Create an app with s2i</p>
<p>oc new-app -i php http://services.lab.example.com/app --name=myapp</p>
<p>Get list of image streams for a specific project.</p>
<p>oc get is -n openshift</p>
<p>Get list of builds</p>
<p>oc get builds</p>
<p>Get list of bc</p>
<p>oc get buildconfig</p>
<p>Get list of templates inside a project where you are not currently</p>
<p>oc get templates -n openshift</p>
<p>Explain: oc process --parameters mysql-persistent -n openshift</p>
<p>list available parameters/resources from a template</p>
<p>Process a template and redirect output to a file</p>
<p>oc process -o yaml -f filename > myapp.yaml</p>
<p>Which OCP resource is responsible for the build step in the S2I process</p>
<p>BuildConfig (BC)</p>
<p>How do you retrieve logs resulting from the S2I build step?</p>
<p>oc logs bc/appname</p>
<p>How do you retrieve logs resulting from the S2I deployment step?</p>
<p>oc logs -f deployment/appname</p>
<p>How do you troubleshoot volume issues in OCP?</p>
<p>1) Delete the persistent volume claim<br></br>2) Delete the persistent volume. <br></br>3) Recreate the persistent volume</p>
<p>Delete persistent volume</p>
<p>oc delete pv</p>
<p>Monitor logs from a build</p>
<p>oc logs -f bc/temps</p>
<p>Flag to configure oc new-app to create a DeploymentConfig resource instead of a Deployment</p>
<p>--as-deployment-config</p>
<p>Flag to provide the image stream to be used</p>
<p>--image-stream<br></br><br></br>-i</p>
<p>Flag to specify if deployment is docker or pipeline or source</p>
<p>--strategy</p>
<p>Flag to provide the URL to a Git repository to be used as input to an S2I build</p>
<p>--code</p>
<p>Flag to provide the URL to a container image to be deployed.</p>
<p>--docker-image</p>
<p>Flag to show the result of the operation without performing it</p>
<p>--dry-run</p>
<p>Flag to provide the path to a directory to treat as the root when creating an app from a git URL</p>
<p>--context-dir</p>
<p>Build app from git url using specific builder image</p>
<p>oc new-app php~http://gitserver.example.com/mygitrepo<br></br><br></br>oc new-app -i php http://gitserver.example.com/mygitrepo<br></br><br></br>oc new-app php:7.0~http://gitserver.example.com/mygitrepo<br></br><br></br>oc new-app -i php:7.0 http://gitserver.example.com/mygitrepo</p>
<p>Diff between tilde (~) and --image-stream (-i) options</p>
<p>-i : requires git client installed locally</p>
<p>- i:language detection needs to clone the repo forinspection</p>
<p>~ : no language detection</p>
<p>~ : no git client needed</p>
<p>Command to retrieve a file inside a running container file system</p>
<p>oc cp frontend-1-zvjhb:/var/log/httpd/error_log \<br></br>/tmp/frontend-server.log</p>
<p>Diff between Linux cp and oc cp</p>
<p>oc cp does not copy a file to a folder.</p>
<p>execute commands inside the container</p>
<p>oc rsh frontend-1-zvjhb ps ax</p>
<p>Start and interactive shell to container</p>
<p>oc rsh -t frontend-1-zvjhb</p>
<p>create a new configuration map that stores string literals</p>
<p>oc create cm config_map_name \<br></br>--from-literal key1=value1 \<br></br>--from-literal key2=value2</p>
<p>create a new secret that stores string literals</p>
<p>oc create secret generic secret_name \<br></br>--from-literal username=user1 \<br></br>--from-literal password=mypa55w0rd</p>
<p>create a new configuration map that stores the contents of a file or a directory containing a set of files</p>
<p>oc create cm config_map_name \<br></br>--from-file /home/demo/conf.txt</p>
<p>create a new secret that stores the contents of a file or a directory containing a set of files</p>
<p>oc create secret generic secret_name \<br></br>--from-file /home/demo/mysecret.txt</p>