文章20 | 阅读 7952 | 点赞0
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx-deploy
template:
metadata:
labels:
app: nginx-deploy
spec:
containers:
- name: nginx-deployment
image: nginx
env:
- name: GET_HOSTS_FROM
value: dns
ports:
- containerPort: 80
kubectl exec nginx-75cd57fb6-v9t84 -it /bin/sh
echo -n "admin" | base64
YWRtaW4=
echo -n "wtl199201180271" | base64
d3RsMTk5MjAxMTgwMjcx
apiVersion: v1
kind: Secret
metadata:
name: mysecret
type: Opaque
data:
password: d3RsMTk5MjAxMTgwMjcx
username: YWRtaW4=
apiVersion: v1
kind: Pod
metadata:
labels:
name: secret-test
name: secret-test
spec:
volumes:
- name: secrets
secret:
secretName: mysecret
containers:
- image: wangyanglinux/myapp:v1
name: db
volumeMounts:
- name: secrets
mountPath: "/etc/secret"
readOnly: true
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: nginx
spec:
replicas: 3
selector:
matchLabels:
tier: nginx-deploy
template:
metadata:
labels:
tier: nginx-deploy
spec:
containers:
- name: nginx-deployment
image: wangyanglinux/myapp:v1
ports:
- containerPort: 80
env:
- name: TEST_USER
valueFrom:
secretKeyRef:
name: mysecret
key: username
- name: TEST_PASSWORD
valueFrom:
secretKeyRef:
name: mysecret
key: password
kubectl create secret docker-registry myregistrykey --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL
myregistrykey
apiVersion: v1
kind: Pod
metadata:
name: pod-test
spec:
containers:
- name: container-test
image: hub.ljxwtl.cn/library/nginx-deployment:v1.0
imagePullSecrets:
- name: myregistrykey
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/wtl1992/article/details/104818982
内容来源于网络,如有侵权,请联系作者删除!