OpenShift 1 Flashcards

(84 cards)

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
Which OCP resource is responsible for the build step in the S2I process
BuildConfig (BC)
26
How do you retrieve logs resulting from the S2I build step?
oc logs bc/appname
27
How do you retrieve logs resulting from the S2I deployment step?
oc logs -f deployment/appname
28
How do you troubleshoot volume issues in OCP?
1) Delete the persistent volume claim 2) Delete the persistent volume. 3) Recreate the persistent volume
29
Delete persistent volume
oc delete pv
30
Monitor logs from a build
oc logs -f bc/temps
31
Flag to configure oc new-app to create a DeploymentConfig resource instead of a Deployment
--as-deployment-config
32
Flag to provide the image stream to be used
--image-stream -i
33
Flag to specify if deployment is docker or pipeline or source
--strategy
34
Flag to provide the URL to a Git repository to be used as input to an S2I build
--code
35
Flag to provide the URL to a container image to be deployed.
--docker-image
36
Flag to show the result of the operation without performing it
--dry-run
37
Flag to provide the path to a directory to treat as the root when creating an app from a git URL
--context-dir
38
Build app from git url using specific builder image
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
Diff between tilde (~) and --image-stream (-i) options
- i : requires git client installed locally - i: language detection needs to clone the repo for inspection ~ : no language detection ~ : no git client needed
40
Command to retrieve a file inside a running container file system
oc cp frontend-1-zvjhb:/var/log/httpd/error\_log \ /tmp/frontend-server.log
41
Diff between Linux cp and oc cp
oc cp does not copy a file to a folder.
42
execute commands inside the container
oc rsh frontend-1-zvjhb ps ax
43
Start and interactive shell to container
oc rsh -t frontend-1-zvjhb
44
create a new configuration map that stores string literals
oc create cm config\_map\_name \ - -from-literal key1=value1 \ - -from-literal key2=value2
45
create a new secret that stores string literals
oc create secret generic secret\_name \ - -from-literal username=user1 \ - -from-literal password=mypa55w0rd
46
create a new configuration map that stores the contents of a file or a directory containing a set of files
oc create cm config\_map\_name \ --from-file /home/demo/conf.txt
47
create a new secret that stores the contents of a file or a directory containing a set of files
oc create secret generic secret\_name \ --from-file /home/demo/mysecret.txt
48
Command to retrieve cm in json
oc get configmap/myconf -o json
49
Command to edit cm
oc edit configmap/myconf
50
Command to alter a cm
oc patch cm/myconf --patch '{"data":{"key1":"newvalue1"}}'
51
inject all values stored in a cm into a deployment
oc set env deployment/my-deployment-name --from configmap/mycm
52
Create secrets to allow OCP to connect to docker registry
oc create secret docker-registry registrycreds \ - -docker-server registry.example.com \ - -docker-username youruser \ - -docker-password yourpassword
53
Link secrets to default service account
oc secrets link default registry-creds-name --for=pull
54
Link secrets registrycreds to builder image
oc secrets link builder registrycreds --for=pull,mount
55
Create a route to expose the internal OCP registry
oc patch config.imageregistry cluster -n openshift-image-registry \ --type merge -p '{"spec":{"defaultRoute":true}}'
56
Show the route of the internal OCP registry
oc get route -n openshift-image-registry
57
Log in into the internal registry from CLI
1) TOKEN=$(oc whoami -t) 2) podman login -u myuser -p ${TOKEN} internal-registry-url
58
allows a user to pull images from the internal registry in a given project
oc policy add-role-to-user system:image-puller \ user\_name -n project\_name
59
Get image stream tags in a project
oc get istag -n openshift
60
create an image stream tag resource for a container image hosted on an external registry
oc import-image myimagestream[:tag] --confirm \ --from registry/myorg/myimage[:tag] oc import-image myimagestream:1.0 --confirm \ --from registry/myorg/myimage
61
create one image stream tag resource for each container image tag that exists in the source registry server
oc import-image myimagestream --confirm --all \ --from registry/myorg/myimage
62
update an image stream tag to match one current image IDs on the source registry server
oc import-image myimagestream[:tag] --confirm
63
Starts a new build manually.
oc start-build name
64
Cancel a build
oc cancel-build name
65
Deletes a build configuration.
oc delete bc/name
66
Delete a build
oc delete build/name-1
67
Describes details about a build configuration resource and the associated builds,
oc describe bc name
68
Describe a build providing the build name:
oc describe build name-1
69
How do you change the number of most recent builds that are persisted
Edit the bc and change following properties: successfulBuildsHistoryLimit, and the failedBuildsHistoryLimit
70
change log level for bc
oc set env bc/name BUILD\_LOGLEVEL="4"
71
Deploy app using pre-created image
oc new-app --docker-image=registry.access.redhat.com/rhel7-mysql57
72
What are the oc-new app option flags?
--as-deployment-config --image-stream --strategy --code --docker-image --dry-run --context-dir
73
Parameters for --strategy
1. docker 2. source 3. pipeline
74
Explain --strategy
Helps in disambiguating if URL contains both docker file and source code
75
Explain --as-deployment-config
Used in oc new-app to use deployment config for the deployment of the app instead of deployment.
76
Create image stream named myis for acme/awesome container image coming from insecure registry.com
oc import-image myis --confirm --from registry.com/acme/awesome --insecure
77
What are image stream tags for?
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
What are different types of secrets?
1. basic-auth 2. opaque 3. service-account-token 4. ssh-auth 5. tls
79
Pod CR
80
Create POD from CLI
**oc run example-pod** **--image=quay.io/example/awesome-container** **--env GREETING='Hello from the awesome container' \ --port=8080**
81
Service CR
82
Create service using CLI
**oc expose pod backend-app --port=8080 --targetPort=8080 --name=backend-app**
83
Deployment CR
84
Create deployment using CLI
**oc create deployment example-deployment** **--image=quay.io/example/awesome-container** **--replicas=3**