Configuration Flashcards

1
Q

How do you create your own image?

A

Create a dockerfile and put all the steps in it, that would be necessary normally, in order.

i.e:
FROM Ubunto

RUN apt-get update
RUN apt-get install python

RUN pip install flask
RUN pip install flask-mysql

COPY . /opt/source-code

ENTRYPOINT FLASK_APP=/opt/source-code/app.py flask run
—X
Then build the Dockerfile
‘docker build Dockerfile -t maratajc/my-custom-app
-> creates the file locally

Then
‘docker push maratajc/my-custom-app’ pushs it to the docker repo

my-custom-app = image name

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

How are Dockerfiles structured?

A

INSTRUCTION ARGUMENT

-> what to do when creating the image

Every dockerfile needs to start from an OS, or an image that was created before, based on an OS (FROM Ubuntu)

RUN instructs to run a certain command on the images
COPY copies files from local system onto the image

ENTRYPOINT allows a command, when an image is run as a container

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

How can you specify commands to be run in a pod at start?

A
spec:
  containers:
	  - name:
	  image:
		command: ["sleep","5000"]

or
~~~
command:
- sleep
- “5000”
~~~

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

How do you add commands/arguments to the command that is run when a container is started?

A

In the Dockerfile
After ENTRYPOINT
add CMD [”–color”, “red”] for final command to have ‘… –color red’

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

What happens when a command in the pod-yaml is different to the Dockerfile?

A
  • only the command from the yaml is run
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In a Dockerfile how do ENTRYPOINT and CMD work together?

A

Whatever is written inside CMD gets appended to the ENTRYPOINT command

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

What happens if in a Dockerfile a CMD instruction is given and in the cl a different instruction is given?

I.e.
ENTRYPOINT [“sleep”]
CMD [“5”]
vs.
docker run ubuntu-sleeper 10

A

The cl instruction overwrites the Dockerfile CMD

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

How can you overwrite an ENTRYPOINT of a Dockerfile?

A

using ‘–entrypoint’ option

docker run –entrypoint sleep2.0 ubuntu sleeper 10

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

How can you specify arguments to be given to the underlying CRI?

A
apiVersion:
kind:
metadata:
spec:
  - name: ubuntu-sleeper
   image: ubuntu-sleeper
	 args: ["10"]
	 
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What information can be changed on an existing pod?

A

spec.containers[x].image

spec.initContainers[x].image

spec.activeDeadlineSeconds

spec.tolerations

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

What is different for changing an existing pod and changing an existing deployment?

A

For pods only specific fields can be changed.

For deployments any field can easily be changed. As a consequence the running pods are replaced

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

How do you set an environemnt variable?

A

In pod/template

spec:
containers:
- name:
image:
env:
- name: App-COLOR
VALUE: pink
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are ways of setting environment variables?

A
  • manually, as key-value directly in spec
  • through a ConfigMap
  • through Secrets
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you set environment variables trough Config maps

A
spec:
-
 ...
 valueFrom
  configMapKeyRef:
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you set environment variables trough Secrets?

A
spec:
...
 - env:
   - name: APP_Color
   secretKeyRef 
How well did you know this?
1
Not at all
2
3
4
5
Perfectly