准备Nginx镜像,并推送到仓库
docker load -i nginx.tar
docker tag nginx:1.18 10.0.7.125:8000/library/nginx:1.18
docker push 10.0.7.125:8000/library/nginx:1.18
nginx-pvc
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nginx
namespace: default
spec:
accessModes:
- ReadWriteOnce
storageClassName: nfs-client
resources:
requests:
storage: 1Gi
nginx-deploy
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: 10.0.7.125:8000/library/nginx:1.18
ports:
- containerPort: 80
volumeMounts:
- mountPath: /usr/share/nginx/html
name: nginx
volumes:
- name: nginx
persistentVolumeClaim:
claimName: nginx
nginx-svc
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
type: NodePort
selector:
app: nginx
ports:
- port: 80
targetPort: 80
nodePort: 30000
访问
http://10.0.7.70:30000