5. Manage Storage for Application Configuration and Data Flashcards

1
Q

Como se forma el yaml con los siguientes datos

Tipo Deployment
Nombre hello-deployment
Replicas 1
Selectors = app: hello-deployment
labels = app: hello-deployment
template = app:deployment
variables de ambiente= ENV_VARIABLE_1
obtiene valor de secreto key: hello y name: world
imagen= quay.io/hello-world

A

apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-deployment
spec:
replicas: 1
selector:
matchLabels:
app: hello-deployment
template:
metadata:
labels:
app: hello-deployment
spec:
containers:
- env:
- name: ENV_VARIABLE_1
valueFrom:
secretKeyRef:
key: hello
name: world
image: quay.io/hello-image:latest

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

Como se forma el configuration map con los siguientes datos de ejemplo:

name: example-configmap
namespace: my-app

example.property.1: hello
example.property.2: world
example.property.file multiple property.1=value-1 property.2=value-2 property.3=value-3
binario bar: L3Jvb3QvMTAw

A

apiVersion: v1
kind: ConfigMap 1
metadata:
name: example-configmap
namespace: my-app
data: 2
example.property.1: hello
example.property.2: world
example.property.file: |-
property.1=value-1
property.2=value-2
property.3=value-3
binaryData: 3
bar: L3Jvb3QvMTAw

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

Como se hace el secreto con los datos siguientes:

name: example-secret
namespace: my-app
data= username: bXl1c2VyCg== password: bXlQQDU1Cg==
stringData= hostname: myapp.mydomain.com
secret properties=
property1=valueA
property2=valueB

A

apiVersion: v1
kind: Secret
metadata:
name: example-secret
namespace: my-app
type: Opaque
data:
username: bXl1c2VyCg==
password: bXlQQDU1Cg==
stringData:
hostname: myapp.mydomain.com
secret.properties: |
property1=valueA
property2=valueB

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

Como se codifica y decodifica

A

echo bXl1c2VyCg== | base64 –decode
echo bXl1c2VyCg== | base64 –code

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

Como se crea un secreto desde command line key1=secret1 y key2=secret2

A

oc create secret generic secret_name \
–from-literal key1=secret1 \
–from-literal key2=secret2

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

Como se crea secreto desde archivos ssh-keys \
id_rsa=/path-to/id_rsa \
id_rsa.pub=/path-to/id_rsa.pub

A

kubectl create secret generic ssh-keys \
–from-file id_rsa=/path-to/id_rsa \
–from-file id_rsa.pub=/path-to/id_rsa.pub

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

Como se crea secreto para TLS

cert /path-to-certificate key /path-to-key

A

oc create secret tls secret-tls \
–cert /path-to-certificate –key /path-to-key

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

Como se crea configuration map my-config desde literal key1=config1 key2=config2

A

kubectl create configmap my-config \
–from-literal key1=config1 –from-literal key2=config2

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

Cual es la estructura del config map name config-map-example
namespace-app

database.name sakila
database.user redhat

A

apiVersion: v1
kind: ConfigMap
metadata:
name: config-map-example
namespace: example-app
data:
database.name: sakila
database.user: redhat

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

Cual es la estructura de yaml para el config map example del pod

name: config-map-example-pod
namespace: example-app

- name: example-container
  image: registry.example.com/mysql-80:1-237
  command: [ "/bin/sh", "-c", "env" ]

    - name: MYSQL_DATABASE 
      valueFrom:
          name: config-map-example
          key: database.name 

    - name: MYSQL_USER
          name: config-map-example
          key: database.user optional: true
A

apiVersion: v1
kind: Pod
metadata:
name: config-map-example-pod
namespace: example-app
spec:
containers:
- name: example-container
image: registry.example.com/mysql-80:1-237
command: [ “/bin/sh”, “-c”, “env” ]
env: 1
- name: MYSQL_DATABASE
valueFrom:
configMapKeyRef:
name: config-map-example
key: database.name
- name: MYSQL_USER
valueFrom:
configMapKeyRef:
name: config-map-example
key: database.user
optional: true

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

Como se puede crear un pod usando variables desde un configmap

A

apiVersion: v1
kind: Pod
metadata:
name: config-map-example-pod
namespace: example-app
spec:
containers:
- name: example-container
image: registry.example.com/mysql-80:1-237
command: [ “/bin/sh”, “-c”, “env” ]
envFrom:
- configMapRef:
name: config-map-example
restartPolicy: Never

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

Como se especifica un pod resource con imagen registry.example.com/mysql-80:1-237 y estableciendo la variable MYSQL_DATABASE y MYSQL_USER desde un config map config-map-example keys

database.name y database.user

A

apiVersion: v1
kind: Pod
metadata:
name: config-map-example-pod
namespace: example-app
spec:
containers:
- name: example-container
image: registry.example.com/mysql-80:1-237
command: [ “/bin/sh”, “-c”, “env” ]
env:
- name: MYSQL_DATABASE
valueFrom:
configMapKeyRef:
name: config-map-example
key: database.name
- name: MYSQL_USER
valueFrom:
configMapKeyRef:
name: config-map-example
key: database.user
optional: true

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

Como se puede exportar la variable TEST_SECRET_UESRNAME__ENV_VAR

desde secreto para pod secret-example-pod image busybox

A

apiVersion: v1
kind: Pod
metadata:
name: secret-example-pod
spec:
containers:
- name: secret-test-container
image: busybox
command: [ “/bin/sh”, “-c”, “export” ]
env:
- name: TEST_SECRET_USERNAME_ENV_VAR
valueFrom:
secretKeyRef:
name: test-secret
key: username

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

Como se monta un secreto demo-user pass zT1KTgk dentro del filesystem /app-secrets llamado demo-secret o desde archivo

volume en el deployment demo

A

oc create secret generic demo-secret \
–from-literal user=demo-user \
–from-literal root_password=zT1KTgk

[user@host ~]$ oc create secret generic demo-secret \
–from-file user=/tmp/demo/user \
–from-file root_password=/tmp/demo/root_password

[user@host ~]$ oc set volume deployment/demo \ 1
–add –type secret \ 2
–secret-name demo-secret \ 3
–mount-path /app-secrets

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

Como usar un config map config-files/http.conf en volumen /app-secrets usando el config map demo-map para el deployment demo

A

oc create configmap demo-map \
–from-file=config-files/httpd.conf

oc set volume deployment/demo \
–add –type configmap \
–configmap-name demo-map \
–mount-path /app-secrets

oc set volume deployment/demo

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

Como se establecen las variables del deployment demo desde el secreto demo-secret prefijo MYSQL_

A

oc set env deployment/demo \
–from secret/demo-secret –prefix MYSQL_

17
Q

Como se extrae un secreto demo-secrets namespace demo para dejarlo en la ruta /tmo/demo para actualizarlo

A

oc extract secret/demo-secrets -n demo \
–to /tmp/demo –confirm

oc set data secret/demo-secrets -n demo \
–from-file /tmp/demo/root_password