k8s 文件最简编写手册

创建命名空间

kind: Namespace
apiVersion: v1
metadata:
  name: biz

创建Deployments

kind: Deployment
apiVersion: apps/v1
metadata:
  namespace: biz
  name: test-app
  labels:
    app: test-app
spec:
  selector: 
    matchLabels:
      app: test-app
  template:
    metadata:
      labels:
        app: test-app
    spec:
      containers:
        - name: test-app
          image: alpine:3.11
          resources:
            limits:
              cpu: 200m # 100m means one hundred millicpu = 0.1 cpu
              memory: 256Mi # or 256M
            requests:
              cpu: 100m
              memory: 128Mi
          command: ["/bin/sh"]
          args: ["-c", "while true; do echo hello; sleep 10; done"]

创建 Service

apiVersion: v1
kind: Service
metadata:
  namespace: biz
  name: test-app
spec:
  ports:
    - port: 8080
      protocol: TCP
  selector:
    app: test-app

创建Ingress

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  namespace: biz
  name: ingress-nginx
spec:
  rules:
    - host: k3s.iamqt.com
      http:
        paths:
          - backend:
              serviceName: test-app
              servicePort: 8080

仅有 1 条评论
  1. liuuuq

    大佬 大佬

    liuuuq 回复
发表新评论取消回复