Multi-Container Pods Flashcards

1
Q

What kind of patterns exist for multi-container pods in Kubernetes?

A
  • Ambassador
  • Sidecar
  • Adapter
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are reasons for multi-container pods and what are consequences for the included containers?

A
  • sometimes close-connection between two services needed
  • both containers share lifecycle, network and storage of the pod
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do we create multi-container pods?

A
  • in yaml add new container in spec section
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a good example of a Sidecar patternß

A
  • deploying a logging agent besides a webserver to collect logs and forward them to a central log server
  • additional container with additional functionality
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an example for the Adapter pattern?

A
  • an adapter container that processes logs and standardizes the format
  • before sending them forward to the centralized server
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an example for the Ambassador pattern?

A
  • i.e when you use three different databases for different environment (prod, dev, test)
  • this connectivity needs to be configured in the application in dependence on the goal environment
  • such logic may be outsourced to a separate container within the pod, so that the application can always refer to the database at localhost and your container will proxy the request to the right database
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

With what command can we see the logs of a running application/pod?

A

kubectl logs app-name -n namespace

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

What happens if any one container in one pod fail?

A
  • the pod restarts
  • all containers within a pod are expected to stay alive
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is initContainers used for?

A
  • to run a task/process that will run only one time when the pod is first created or a process that waits for an external service or database to be up before the actual application starts
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do we configure a initContainer ?

A

in pod yaml:

spec: 
 containers:
  - name:
initContainers:
 - name: init-myservice
   image: busybox
	 command: ['sh', '-c', 'git clone < some repo that will be used by the application;']
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How does the initContainer work?

A
  • when pod first created, the initContainer is run
  • process in initContainer must run to completion before the real container hosting the application starts
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Are multiple initContainers possible? What about sequence and failure?

A

Yes
- each initContainer is then run one at a time in a sequential order
- if any of the initContainer fails to complete, pod is restarted until it succeeds

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