Eu criei a aplicação: deployment, volume, loadbalancer, banco de dados. Meu dashboard está assim:
Esses são meus arquivos:
vollmed-api-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: vollmed-api-deployment
labels:
app: vollmed-api
spec:
replicas: 3
selector:
matchLabels:
app: vollmed-api
template:
metadata:
labels:
app: vollmed-api
spec:
containers:
- name: vollmed-api
image: leonardosartorello/vollmed:v8
ports:
- containerPort: 3000
env:
# Define the environment variable
- name: DB_HOST # Notice that the case is different here
# from the key name in the ConfigMap.
valueFrom:
configMapKeyRef:
name: vollmed-configmap # The ConfigMap this value comes from.
key: DB_HOST # The key to fetch.
- name: DB_DATABASE # Notice that the case is different here
# from the key name in the ConfigMap.
valueFrom:
configMapKeyRef:
name: vollmed-configmap # The ConfigMap this value comes from.
key: DB_DATABASE # The key to fetch.
- name: DB_PASSWORD # Notice that the case is different here
# from the key name in the ConfigMap.
valueFrom:
secretKeyRef:
name: vollmed-secret # The ConfigMap this value comes from.
key: DB_PASSWORD # The key to fetch.
# livenessProbe:
# httpGet:
# path: /paciente
# port: 3000
# initialDelaySeconds: 10
# periodSeconds: 3
vollmed-api-loadbalancer.yaml
apiVersion: v1
kind: Service
metadata:
name: vollmed-api-loadbalancer
spec:
type: LoadBalancer
selector:
app: vollmed-api
ports:
# By default and for convenience, the `targetPort` is set to the same value as the `port` field.
- port: 3000
targetPort: 3000
vollmed-mysql-statefulset.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql
spec:
selector:
matchLabels:
app: mysql # has to match .spec.template.metadata.labels
serviceName: "mysql"
replicas: 1 # by default is 1
minReadySeconds: 10 # by default is 0
template:
metadata:
labels:
app: mysql # has to match .spec.selector.matchLabels
spec:
terminationGracePeriodSeconds: 10
containers:
- name: mysql
image: mysql:8
ports:
- containerPort: 3306
name: mysql
env:
- name: MYSQL_DATABASE # Notice that the case is different here
# from the key name in the ConfigMap.
valueFrom:
configMapKeyRef:
name: vollmed-configmap # The ConfigMap this value comes from.
key: DB_DATABASE # The key to fetch.
- name: MYSQL_ROOT_PASSWORD # Notice that the case is different here
# from the key name in the ConfigMap.
valueFrom:
secretKeyRef:
name: vollmed-secret # The ConfigMap this value comes from.
key: DB_PASSWORD # The key to fetch.
volumeMounts:
- name: vollmed-mysql-pv
mountPath: /var/lib/mysql
volumes:
- name: vollmed-mysql-pv
persistentVolumeClaim:
claimName: vollmed-mysql-pvc
vollmed-mysql-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: vollmed-mysql-svc
labels:
app: mysql
spec:
ports:
- port: 3306
name: mysql
clusterIP: None
selector:
app: mysql
vollmed-mysql-volume.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: vollmed-mysql-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 15Gi
storageClassName: csi-hostpath-sc
Tive que deixar o livenessProbe desabilitado porque a requisição está quebrando.
Eu havia conseguido antes, acessando pelo IP da minha máquina e a porta 3000. Mas precisei reinstalar o minikube e refazer tudo de novo, porém agora a requisção quebra. No meu dashboard o loadbalancer fica sempre pendente: