k8s常用命令

290次阅读
没有评论

共计 615 个字符,预计需要花费 2 分钟才能阅读完成。

内容目录

k8s 常用命令

kubectl get svc -n default
kubectl delete svc svs-name -n default
kubectl get pods -o wide
kubectl get deployment
kubectl delete pod jenkins2-8698b5449c-grbdm -n default

Deployment 模板

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:1.7.9
          ports:
            - containerPort: 80
            - containerPort: 3000

Service 模板

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  labels:
    app: nginx
spec:
  externalTrafficPolicy: Cluster
  ports:
    - port: 3010 # 宿主的端口
      protocol: TCP
      targetPort: 80 # POD 的端口
  selector:
    # 指定目标应用
    app: nginx
  type: LoadBalancer

正文完
 
评论(没有评论)