标签:term desire 没有 cluster des none node节点 roc src
nginx yaml文件说明---
#定义nginx命名空间
apiVersion: v1
kind: Namespace
metadata:
name: k8s-nginx #自定义的命名空间
---
#定义nginx service
apiVersion: v1
kind: Service
metadata:
name: k8s-nginx
namespace: k8s-nginx
labels:
app: k8s-nginx
spec:
type: NodePort
ports:
- port: 80 #分配集群ip的端口
targetPort: 80 #分配pod端口
nodePort: 10280 #node节点端口
protocol: TCP
clusterIP: 169.169.249.80 #分配集群ip
selector:
app: k8s-nginx
---
#创建 deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deploy
namespace: k8s-nginx
labels:
app: k8s-nginx
spec:
replicas: 2 #生成复本数量为2
selector:
matchLabels:
app: k8s-nginx
template:
metadata:
labels:
app: k8s-nginx
annotations:
app: nginx-clouster
spec:
containers:
- name: nginx
image: docker.io/nginx
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: 300m
memory: 3000Mi
requests:
cpu: 100m
memory: 100Mi
ports:
- containerPort: 80
如果要修改nginx.yaml文件,二种方式
第一种:
直接修改 nginx.yaml并保存
kubectl apply -f nginx.yaml
第二种:
先查看要修改的资源对象
#kubectl get pod,svc,deploy -n k8s-nginx
NAME READY STATUS RESTARTS AGE
pod/nginx-deploy-5d677c4495-5wmf2 1/1 Running 0 26m
pod/nginx-deploy-5d677c4495-lzv6g 1/1 Running 0 37m
pod/nginx-deploy-5d677c4495-rpfgg 1/1 Running 0 37m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/k8s-nginx NodePort 169.169.249.80 <none> 80:10280/TCP 42m
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deployment.extensions/nginx-deploy 3 3 3 3 39m
然后再执行以下命令
kubectl edit deployment.extensions/nginx-deploy -n k8s-nginx
直接编辑,完成后保存,保存后要查看是否出错,如果没有出错会立即生效,如果有出错,下面会出现error字样,并在/tmp下生成一个临时文件,此时原文件并没有修改,不会影响线上业务
标签:term desire 没有 cluster des none node节点 roc src
原文地址:http://blog.51cto.com/running/2324468