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
- ConfigMap parameters
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
- Secrect 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
- create 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