OpenShift 1 Flashcards

1
Q

Kubernetes main resource types

A

POD (po)
Persistent Volumes (pv)
Persistent Volume Claims (pvc)
Build Config (bc)
Deployment / deployment Confg (dc)
Services (svc)
Config Maps (cm)
Secrets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Login to OCP cluster using CLI

A

oc login -u user1 -p passwd URL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Forward port to mysql server

A

oc port-forward mysql 3306:3306

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Deploy mysql using template

A

oc new-app

  • -template=mysql-persistent
  • p MYSQL_USER=user1
  • p MYSQL_PASSWORD=mypa55
  • p MYSQL_DATABASE=testdb
  • p MYSQL_ROOT_PASSWORD=r00tpa55
  • p VOLUME_CAPACITY=10Gi
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Deploy mysql using image from registry

A

oc new-app –image=myregistry.com/mycompany/myapp –name=myapp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Deploy app using github url

A

oc new-app https://github.com/openshift/ruby-hello-world –name=ruby-hello

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Deploy mysql using mysql image

A

oc new-app mysql MYSQL_USER=user MYSQL_PASSWORD=pass MYSQL_DATABASE=testdb -l db=mysql

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Get list of pv

A

oc get pv

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Create pv

A

oc create -f pvc.yaml

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

get certain resources

A

oc get RESOURCE_TYPE RESOURCE_NAME

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Show detailed of the resource

A

oc describe resource_type resource_name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

oc create

A

oc create

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

edit resource

A

oc edit deploymentconfig/parksmap-katacoda

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Delete resource

A

oc delete RESOURCE_TYPE name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Search by label

A

oc get svc,deployments -l app=nexus

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Create a route

A

oc expose svc quotedb –name quote

oc expose object_type object_name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Restart an OCP build

A

oc start-build myapp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Create an app with s2i

A

oc new-app -i php http://services.lab.example.com/app –name=myapp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Get list of image streams for a specific project.

A

oc get is -n openshift

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Get list of builds

A

oc get builds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Get list of bc

A

oc get buildconfig

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Get list of templates inside a project where you are not currently

A

oc get templates -n openshift

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Explain: oc process –parameters mysql-persistent -n openshift

A

list available parameters/resources from a template

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Process a template and redirect output to a file

A

oc process -o yaml -f filename > myapp.yaml

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Which OCP resource is responsible for the build step in the S2I process

A

BuildConfig (BC)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

How do you retrieve logs resulting from the S2I build step?

A

oc logs bc/appname

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

How do you retrieve logs resulting from the S2I deployment step?

A

oc logs -f deployment/appname

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

How do you troubleshoot volume issues in OCP?

A

1) Delete the persistent volume claim
2) Delete the persistent volume.
3) Recreate the persistent volume

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Delete persistent volume

A

oc delete pv

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

Monitor logs from a build

A

oc logs -f bc/temps

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

Flag to configure oc new-app to create a DeploymentConfig resource instead of a Deployment

A

–as-deployment-config

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

Flag to provide the image stream to be used

A

–image-stream

-i

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

Flag to specify if deployment is docker or pipeline or source

A

–strategy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

Flag to provide the URL to a Git repository to be used as input to an S2I build

A

–code

35
Q

Flag to provide the URL to a container image to be deployed.

A

–docker-image

36
Q

Flag to show the result of the operation without performing it

A

–dry-run

37
Q

Flag to provide the path to a directory to treat as the root when creating an app from a git URL

A

–context-dir

38
Q

Build app from git url using specific builder image

A

oc new-app php~http://gitserver.example.com/mygitrepo

oc new-app -i php http://gitserver.example.com/mygitrepo

oc new-app php:7.0~http://gitserver.example.com/mygitrepo

oc new-app -i php:7.0 http://gitserver.example.com/mygitrepo

39
Q

Diff between tilde (~) and –image-stream (-i) options

A
  • i : requires git client installed locally
  • i: language detection needs to clone the repo for inspection

~ : no language detection

~ : no git client needed

40
Q

Command to retrieve a file inside a running container file system

A

oc cp frontend-1-zvjhb:/var/log/httpd/error_log \
/tmp/frontend-server.log

41
Q

Diff between Linux cp and oc cp

A

oc cp does not copy a file to a folder.

42
Q

execute commands inside the container

A

oc rsh frontend-1-zvjhb ps ax

43
Q

Start and interactive shell to container

A

oc rsh -t frontend-1-zvjhb

44
Q

create a new configuration map that stores string literals

A

oc create cm config_map_name \

  • -from-literal key1=value1 \
  • -from-literal key2=value2
45
Q

create a new secret that stores string literals

A

oc create secret generic secret_name \

  • -from-literal username=user1 \
  • -from-literal password=mypa55w0rd
46
Q

create a new configuration map that stores the contents of a file or a directory containing a set of files

A

oc create cm config_map_name \
–from-file /home/demo/conf.txt

47
Q

create a new secret that stores the contents of a file or a directory containing a set of files

A

oc create secret generic secret_name \
–from-file /home/demo/mysecret.txt

48
Q

Command to retrieve cm in json

A

oc get configmap/myconf -o json

49
Q

Command to edit cm

A

oc edit configmap/myconf

50
Q

Command to alter a cm

A

oc patch cm/myconf –patch ‘{“data”:{“key1”:”newvalue1”}}’

51
Q

inject all values stored in a cm into a deployment

A

oc set env deployment/my-deployment-name –from configmap/mycm

52
Q

Create secrets to allow OCP to connect to docker registry

A

oc create secret docker-registry registrycreds \

  • -docker-server registry.example.com \
  • -docker-username youruser \
  • -docker-password yourpassword
53
Q

Link secrets to default service account

A

oc secrets link default registry-creds-name –for=pull

54
Q

Link secrets registrycreds to builder image

A

oc secrets link builder registrycreds –for=pull,mount

55
Q

Create a route to expose the internal OCP registry

A

oc patch config.imageregistry cluster -n openshift-image-registry \
–type merge -p ‘{“spec”:{“defaultRoute”:true}}’

56
Q

Show the route of the internal OCP registry

A

oc get route -n openshift-image-registry

57
Q

Log in into the internal registry from CLI

A

1) TOKEN=$(oc whoami -t)
2) podman login -u myuser -p ${TOKEN} internal-registry-url

58
Q

allows a user to pull images from the internal registry in a given project

A

oc policy add-role-to-user system:image-puller \
user_name -n project_name

59
Q

Get image stream tags in a project

A

oc get istag -n openshift

60
Q

create an image stream tag resource for a container image hosted on an external registry

A

oc import-image myimagestream[:tag] –confirm \
–from registry/myorg/myimage[:tag]

oc import-image myimagestream:1.0 –confirm \
–from registry/myorg/myimage

61
Q

create one image stream tag resource for each container image tag that exists in the source registry server

A

oc import-image myimagestream –confirm –all \
–from registry/myorg/myimage

62
Q

update an image stream tag to match one current image IDs on the source registry server

A

oc import-image myimagestream[:tag] –confirm

63
Q

Starts a new build manually.

A

oc start-build name

64
Q

Cancel a build

A

oc cancel-build name

65
Q

Deletes a build configuration.

A

oc delete bc/name

66
Q

Delete a build

A

oc delete build/name-1

67
Q

Describes details about a build configuration resource and the associated builds,

A

oc describe bc name

68
Q

Describe a build providing the build name:

A

oc describe build name-1

69
Q

How do you change the number of most recent builds that are persisted

A

Edit the bc and change following properties:

successfulBuildsHistoryLimit, and the failedBuildsHistoryLimit

70
Q

change log level for bc

A

oc set env bc/name BUILD_LOGLEVEL=”4”

71
Q

Deploy app using pre-created image

A

oc new-app –docker-image=registry.access.redhat.com/rhel7-mysql57

72
Q

What are the oc-new app option flags?

A

–as-deployment-config

–image-stream

–strategy

–code

–docker-image

–dry-run

–context-dir

73
Q

Parameters for –strategy

A
  1. docker
  2. source
  3. pipeline
74
Q

Explain –strategy

A

Helps in disambiguating if URL contains both docker file and source code

75
Q

Explain –as-deployment-config

A

Used in oc new-app to use deployment config for the deployment of the app instead of deployment.

76
Q

Create image stream named myis for acme/awesome container image coming from insecure registry.com

A

oc import-image myis –confirm –from registry.com/acme/awesome –insecure

77
Q

What are image stream tags for?

A

1) points to new container tag
2) alternative friendly name for the container image

Examples:

1) ruby:2.5 for container image rhel8/ruby-25.
2) ruby:2.6 for container image rhel8/ruby-26

78
Q

What are different types of secrets?

A
  1. basic-auth
  2. opaque
  3. service-account-token
  4. ssh-auth
  5. tls
79
Q

Pod CR

A
80
Q

Create POD from CLI

A

oc run example-pod

–image=quay.io/example/awesome-container

–env GREETING=’Hello from the awesome container’ \ –port=8080

81
Q

Service CR

A
82
Q

Create service using CLI

A

oc expose pod backend-app –port=8080 –targetPort=8080 –name=backend-app

83
Q

Deployment CR

A
84
Q

Create deployment using CLI

A

oc create deployment example-deployment

–image=quay.io/example/awesome-container

–replicas=3