EX288 Merge Flashcards

(156 cards)

1
Q

<p>Create image stream</p>

A

<p>oc import-image stream-name --from URL/${USER}/image-name --confirm</p>

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

<p>Get OCP internal registry URL</p>

A

<p>oc get route -n openshift-image-registry</p>

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

<p>Enable access to internal registry</p>

A

<p>oc patch config.imageregistry cluster -n openshift-image-registry --type merge -p '{"spec":{"defaultRoute":true}}'</p>

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

<p>Create webhook</p>

A

<p>oc set triggers bc/name --from-gitlab</p>

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

<p>Mount cm into deployment</p>

A

<p>oc set env deployment/my-deployment-name --from configmap/mycm</p>

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

<p>Create secrets for OCP to access external registry using username & password</p>

A

<p>oc create secret docker-registry quayio<br></br>--docker-server=$SERVER<br></br>--docker-username=$USERNAME<br></br>--docker-password=$PASSWORD</p>

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

<p>Link secrets to access external registry</p>

A

<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>

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

<p>Set a command as post commit build hook</p>

A

<p>oc set build-hook bc/name --post-commit --command -- bundle exec rake test --verbose</p>

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

<p>Set a post commit build hook using the shell approach</p>

A

<p>oc set build-hook bc/name --post-commit --script="curl http://api.com/user/${USER}"</p>

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

<p>How do you check if credentials have been added properly for accessing external registry?</p>

A

<p>oc describe serviceaccount default</p>

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

<p>Determine which SCC permissions are required for a pod to run</p>

A

<p>oc get pod podname -o yaml | oc adm policy scc-subject-review -f -</p>

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

<p>Create a service account</p>

A

<p>oc create sa nginx-sa</p>

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

<p>Connect the service accountnginx-sato the SCCanyuid:</p>

A

<p>oc adm policy add-scc-to-user anyuid -z nginx-sa</p>

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

<p>Bind the service accountnginx-sato the pod orsccnginxdeployment to allow it to run with its new permissions</p>

A

<p>oc set sa deploy podname nginx-sa</p>

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

<p>List of steps to resolve nginx CrashLoopBackoff</p>

A

<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>

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

<p>Kubernetes main resource types</p>

A

<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>

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

<p>Login to OCP cluster using CLI</p>

A

<p>oc login -u user1 -p passwd URL</p>

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

<p>Forward port to mysql server</p>

A

<p>oc port-forward mysql 3306:3306</p>

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

<p>Deploy mysql using template</p>

A

<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>

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

<p>Deploy mysql using image from registry</p>

A

<p>oc new-app --image=myregistry.com/mycompany/myapp --name=myapp</p>

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

<p>Deploy app using github url</p>

A

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

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

<p>Deploy mysql using mysql image</p>

A

<p>oc new-app mysql MYSQL_USER=user MYSQL_PASSWORD=pass MYSQL_DATABASE=testdb -l db=mysql</p>

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

<p>Get list of pv</p>

A

<p>oc get pv</p>

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

<p>Create pv</p>

A

<p>oc create -f pvc.yaml</p>

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

get certain resources

oc get RESOURCE_TYPE RESOURCE_NAME

26

Show detailed of the resource

oc describe resource_type resource_name

27

oc create

oc create

28

edit resource

oc edit deploymentconfig/parksmap-katacoda

29

Delete resource

oc delete RESOURCE_TYPE name

30

Search by label

oc get svc,deployments -l app=nexus

31

Create a route

oc expose svc quotedb --name quote

oc expose object_type object_name

32

Restart an OCP build

oc start-build myapp

33

Create an app with s2i

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

34

Get list of image streams for a specific project.

oc get is -n openshift

35

Get list of builds

oc get builds

36

Get list of bc

oc get buildconfig

37

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

oc get templates -n openshift

38

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

list available parameters/resources from a template

39

Process a template and redirect output to a file

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

40

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

BuildConfig (BC)

41

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

oc logs bc/appname

42

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

oc logs -f deployment/appname

43

How do you troubleshoot volume issues in OCP?

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

44

Delete persistent volume

oc delete pv

45

Monitor logs from a build

oc logs -f bc/temps

46

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

--as-deployment-config

47

Flag to provide the image stream to be used

--image-stream

-i

48

Flag to specify if deployment is docker or pipeline or source

--strategy

49

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

--code

50

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

--docker-image

51

Flag to show the result of the operation without performing it

--dry-run

52

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

--context-dir

53

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

54

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

55

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

56

Diff between Linux cp and oc cp

oc cp does not copy a file to a folder.

57

execute commands inside the container

oc rsh frontend-1-zvjhb ps ax

58

Start and interactive shell to container

oc rsh -t frontend-1-zvjhb

59

create a new configuration map that stores string literals

oc create cm config_map_name \
--from-literal key1=value1 \
--from-literal key2=value2

60

create a new secret that stores string literals

oc create secret generic secret_name \
--from-literal username=user1 \
--from-literal password=mypa55w0rd

61

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

62

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

63

Command to retrieve cm in json

oc get configmap/myconf -o json

64

Command to edit cm

oc edit configmap/myconf

65

Command to alter a cm

oc patch cm/myconf --patch '{"data":{"key1":"newvalue1"}}'

66

inject all values stored in a cm into a deployment

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

67

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

68

Link secrets to default service account

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

69

Link secrets registrycreds to builder image

oc secrets link builder registrycreds --for=pull,mount

70

Create a route to expose the internal OCP registry

oc patch config.imageregistry cluster -n openshift-image-registry \
--type merge -p '{"spec":{"defaultRoute":true}}'

71

Show the route of the internal OCP registry

oc get route -n openshift-image-registry

72

Log in into the internal registry from CLI

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

73

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

74

Get image stream tags in a project

oc get istag -n openshift

75

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

76

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

77

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

oc import-image myimagestream[:tag] --confirm

78

Starts a new build manually.

oc start-build name

79

Cancel a build

oc cancel-build name

80

Deletes a build configuration.

oc delete bc/name

81

Delete a build

oc delete build/name-1

82

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

oc describe bc name

83

Describe a build providing the build name:

oc describe build name-1

84

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

Edit the bc and change following properties:

successfulBuildsHistoryLimit, and the failedBuildsHistoryLimit

85

change log level for bc

oc set env bc/name BUILD_LOGLEVEL="4"

86

Deploy app using pre-created image

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

87

What are the oc-new app option flags?

--as-deployment-config

 

--image-stream

--strategy

--code

--docker-image

--dry-run

--context-dir

88

Parameters for --strategy

  1. docker 
  2. source
  3. pipeline
89

Explain --strategy

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

90

Explain --as-deployment-config 

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

91

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

92

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 

93

What are different types of secrets?

  1. basic-auth
  2. opaque
  3. service-account-token
  4. ssh-auth
  5. tls 
94

Two type of bc triggers

Image change triggers
Webhook triggers

95

How do you view the triggers associated with a build configuration

oc describe bc/name

96

Add an image change trigger to a build

oc set triggers bc/name --from-image=project/image:tag

97

How do you remove an image change trigger from a bc

oc set triggers bc/name --from-image=project/image:tag --remove

98

Add a webhook to a bc

oc set triggers bc/name --from-gitlab

oc set triggers bc/name --from-github

oc set triggers bc/name --from-bitbucket

99

Remove a webhook from a bc

oc set triggers bc/name --from-gitlab --remove

oc set triggers bc/name --from-github --remove

oc set triggers bc/name --from-bitbucket --remove

100

What are the two types of post commit hooks?

Command: A executed using the exec system call.

Shell script: Runs a build hook with the /bin/sh -ic command

101

Create a command post-commit build hook

oc set build-hook bc/name --post-commit \
--command -- bundle exec rake test --verbose

102

Create a shell script post-commit build hook

oc set build-hook bc/name --post-commit \
--script="curl http://api.com/user/${USER}"

103

How do you tell S2I where to find its mandatory scripts (run, assemble)

Set io.openshift.s2i.scripts-url as label in the builder image

104

Ways to customize the s2i script:

1) override the default S2I scripts by providing your own S2I scripts in the .s2i/bin

2) create a wrapper script that invokes the default scripts, and then adds the necessary customization before or after the invocation

105

using skopeo how do you determine the location of the s2i script for rhscl/php-73-rhel7 S2I builder image

skopeo inspect
docker://myregistry.com/rhscl/php-73-rhel7 | grep io.openshift.s2i.scripts-url

106

Command for skafolding s2i builder image

s2i create image_name directory

107

How do yous pecify the maven repo URL when creating an app?

--build-env MAVEN_MIRROR_URL=${URL}

108

How to specify a build env variable for oc new-app?

--build-env ENV_VAR_NAME=VALUE

 

Do not put a space after the environment variable ENV_VAR_NAME=VALUE. The environment variable follows the NAME=VALUE format.

109

Types of post commit build hookds

  1. Command
  2. Shell script
110

Set a command as post commit build hook

oc set build-hook bc/name --post-commit --command -- bundle exec rake test --verbose

111

Set a post commit build hook using the shell approach

oc set build-hook bc/name --post-commit \ --script="curl http://api.com/user/${USER}"

112

Start a build called hook and display logs

oc start-build hook -F

113

Where do you put your s2i customizations

In your project under .s2i/bin 

114

How do you invoke the s2i run script during customization?

exec /usr/libexec/s2i/run

 

You must use exec to ensure that the default run script still runs with process ID 1. 

115

Create app from template stored in local file

oc new-app --file mytemplate.yaml -p PARAM1=value1

116

Apply values to a template and store the result in a local file

oc process -f mytemplate.yaml -p PARAM1=value1 > myresourcelist.yaml

117

list only parameters defined by a template

oc process -f mytemplate.yaml --parameters

118

Print the list of env variable in a bc

oc set env bc/hook --list

119

How do you validate a helm chart?

helm lint hello-world

120

How do you render the template locally for quick feedback?

helm template ./hello-world

121

How do you install a helm chart into the Kubernetes cluster:

helm install --name hello-world ./hello-world

122

How to find out which charts are installed on a cluster?

helm ls --all

123

How to upgrade a release to a specified or current version of the chart or configuration

helm upgrade hello-world ./hello-world

124
a

helm rollback hello-world 1

125

How to uninstall a release completely from k8s?

helm uninstall hello-world

126

How to create a versioned archive file of a helm chart?

helm package ./hello-world

127

How to search a helm repo?

helm search repo

128

show the status of a helm release

helm status RELEASE_NAME

129

downloads the charts added as dependencies to a chart

helm dependency update

130

Initialize a helm project

helm create hello-world

131

Configure helm deployment to use a specific image

In values.yaml, change the value of image.repository and image.tag.

132

Add mariadb dependency

in Chats.yaml add:


dependencies:
    - name: mariadb
      version: 11.0.13
      repository: https://charts.bitnami.com/bitnami


Then run: helm dependency update

133

Specify environment variables with helm

In values.yaml, add:


env:
- name: "QUOTES_HOSTNAME"
  value: "famousapp-mariadb"
- name: "QUOTES_DATABASE"
  value: "quotesdb"
- name: "QUOTES_USER"
  value: "quotes"
- name: "QUOTES_PASSWORD"
  value: "quotespwd"

134

Tree types of probes

startup, readiness, liveness

135

What does readiness probe determines?

whether or not a container is ready to serve requests

136

What happens if an app fails readiness probe?

OpenShift removes the IP address for the container from the endpoints of all services.

137

What happens container fails liveness probe?

OCP kills the container and tries to redeploy it

138

Readiness probe config key

spec.containers.readinessprobe

139

Liveness probe config key

spec.containers.livenessprobe

140

Five options that control probes

  1. initialDelaySeconds
  2. timeoutSeconds
  3. periodSeconds
  4. successThreshold
  5. failureThreshold
141

Three protocols for probe execution

  1. http
  2. exec
  3. tcp socket
142

How do you edit deployment using the GUI

Edith the deployment YAML by going to Workloads → Deployment →  

143

Create http readiness probe using oc

oc set probe deployment myapp --readiness --get-url=http://:8080/healthz --period=20

144

Create tcp liveness probe using oc

oc set probe deployment myapp --liveness --open-tcp=3306 --period=20 --timeout-seconds=1

145

Get help with probe creation

oc set probe --help

146

Continuously run "oc get pods"

watch -n 2 oc get pods

147

Set an env variable on a dc

oc set env dc/mysql HOOK_RETRIES=5

148

Start a deployment

 oc rollout latest dc/name

149

view the history of deployments

oc rollout history dc/name

150

See details of a specific deployment

oc rollout history dc/name --revision=1

151

Retry a deployment that failed previously

oc rollout retry dc/name

152

scale the number of pods in a deployment

oc scale dc/name --replicas=3

153

Two types of events that trigger a deployment:

  • Configuration change
  • Image change
154

Set a deployment trigger for a deployment configuration

oc set triggers dc/name --from-image=myproject/origin-ruby-sample:latest -c helloworld

155

Deploy java app by specifying maven repo

oc new-app --as-deployment-config --name quip

 

--build-env MAVEN_MIRROR_URL=URL 

 https://github.com/user/app-deploy

156

Activate readiness and liveness probes for an application

oc set probe dc/quip  --liveness --readiness --get-url=http://:8080/ready  --initial-delay-seconds=30 --timeout-seconds=2