Github CD Setting

Local link to Kubernetes cluster

$gcloud container clusters get-credentials cluster-id --zone asia-east1-b --project project-id

Setting file

ConfigMap.yml

apiVersion: v1
kind: ConfigMap
metadata:
name: dev-data-api-config
namespace: default
data:
api.url: |
STREAMING_API=http://data-api-service

service.yml

apiVersion: v1
kind: Service
metadata:
name: data-api-service
spec:
selector:
app: data-api
ports:
- protocol: TCP
port: 80
targetPort: 8999

development.yml

apiVersion: apps/v1
kind: Deployment
metadata:
name: data-api
spec:
selector:
matchLabels:
app: data-api
replicas: 1
template:
metadata:
labels:
app: data-api
spec:
containers:
- name: data-api
image: asia.gcr.io/project-id/data-api:IMAGE_TAG
ports:
- containerPort: 8999
volumeMounts:
- name: config-volume
mountPath: /app/config
volumes:
- name: config-volume
configMap:
name: dev-data-api-config
items:
- key: api.url
path: api_config
spec:
selector:
matchLabels:
app: statistic-api
replicas: 1
template:
metadata:
labels:
app: statistic-api
spec:
containers:
- name: statistic-api
image: asia.gcr.io/project-id/statistics-api:IMAGE_TAG
ports:
- containerPort: 8080
volumeMounts:
- mountPath: /app/.env
subPath: .env
name: config-secret
volumes:
- secret:
secretName: myproject-config
items:
- key: .env
path: .env
name: config-secret

…/…/MyProject

kubectl create secret generic myproject-config --from-file=./.env
$kubectl get pods
$kubectl get services

在本地端直接連到pod

$kubectl port-forward pod-id 8999:8999