Kubernetes - Variáveis de ambiente
Beatriz813
Posted on September 24, 2022
Declarando as variáveis diretamente no aquivo yml do Pod:
apiVersion: v1
kind: Pod
metadata:
name: db-noticias
labels:
app: db-noticias
spec:
containers:
- name: db-noticias-container
image: aluracursos/mysql-db:1
ports:
- containerPort: 3306
env:
- name: "MYSQL_ROOT_PASSWORD"
value: "q1w2e3r4"
- name: "MYSQL_DATABASE"
value: "empresa"
- name: "MYSQL_PASSWORD"
value: "q1w2e3r4"
Criando um serviço de configMap:
apiVersion: v1
kind: ConfigMap
metadata:
name: db-configmap
data:
MYSQL_ROOT_PASSWORD: q1w2e3r4
MYSQL_DATABASE: empresa
MYSQL_PASSWORD: q1w2e3r4
Primeira forma de vincular o pod com as variáveis do configMap:
apiVersion: v1
kind: Pod
metadata:
name: db-noticias
labels:
app: db-noticias
spec:
containers:
- name: db-noticias-container
image: aluracursos/mysql-db:1
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
configMapKeyRef:
name: db-configmap
key: MYSQL_ROOT_PASSWORD
Segunda forma de vincular o pod com as variáveis do configMap, copiando todas as variáveis definidas no configMap:
apiVersion: v1
kind: Pod
metadata:
name: db-noticias
labels:
app: db-noticias
spec:
containers:
- name: db-noticias-container
image: aluracursos/mysql-db:1
ports:
- containerPort: 3306
envFrom:
- configMapRef:
name: db-configmap
💖 💪 🙅 🚩
Beatriz813
Posted on September 24, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.