侧边栏壁纸
博主头像
DJ's Blog博主等级

行动起来,活在当下

  • 累计撰写 133 篇文章
  • 累计创建 51 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

【Kubernetes】Yaml

Administrator
2022-08-16 / 0 评论 / 0 点赞 / 119 阅读 / 2348 字

【Kubernetes】Yaml

Three Parts


  • 查看deployment的status信息
kubectl get deployment whoami-deployment -o yaml

Format

Yaml文件格式校验工具:https://codebeautify.org/yaml-validator

Template


Labels & Selector



Demo

  • deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: springboot-demo
  labels:
    app: springboot-demo
spec:
  replicas: 1
  selector:
    # 选择labels是app:springboot-demo的pod
    matchLabels:
      app: springboot-demo
  template:
    metadata:
      name: springboot-demo
      labels:
        app: springboot-demo
    spec:
      containers:
        - name: springboot-demo
          image: registry.cn-hangzhou.aliyuncs.com/djflying/springboot-demo:main
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 8080
  • service
apiVersion: v1
kind: Service
metadata:
  name: springboot-demo
spec:
  selector:
    # 先择labels是app:springboot-demo的deployment和pod
    app: springboot-demo
  ports:
    - port: 80
      protocol: TCP
      targetPort: 8080
  type: ClusterIP
  • pod
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  containers:
    - name: nginx
      image: nginx
      ports:
        - containerPort: 80
0

评论区