配置清单--模版

配置清单--模版

deployment模版

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: ingress-ingress
  namespace: default
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
    - host: www.test.com #假域名,需要本地添加hosts
      http:
        paths:
          - path: /
            backend:
              serviceName: nginx1
              servicePort: 8088 #service暴露端口
---
apiVersion: v1
kind: Service
metadata:
  name: nginx1
spec:
  selector:
    app: nginx1
  ports:
    - name: http
      port: 8088  #service端口
      targetPort: 80 #pod容器内部端口
      nodePort: 30001 #NodePort暴露端口,范围30000-32767。ip+端口访问
      protocol: "TCP"
    - name: https
      port: 443
      targetPort: 443
      protocol: "TCP"
  type: NodePort

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx1
  template:
    metadata:
      labels:
        app: nginx1
    spec:
      containers:
        - name: nginx1
          image: nginx:1.21.3

pod静态资源模版

apiVersion: v1
kind: Service
metadata:
  name: nginx2
spec:
  selector:
    app: nginx2
  ports:
    - name: http
      port: 8088
      targetPort: 80
      nodePort: 30002
      protocol: "TCP"
    - name: https
      port: 443
      targetPort: 443
      protocol: "TCP"
  type: NodePort

---
apiVersion: v1
kind: Pod
metadata:
  name: nginx2
  labels:
    app: nginx2
spec:
  containers:
    - name: nginx2
      image: nginx:1.21.3

mysql模版

apiVersion: v1
kind: Namespace
metadata:
  name: sg-bs
  labels:
    app: sg-bs
---
apiVersion: v1
kind: Service
metadata:
  name: mysql
  namespace: sg-bs
spec:
  selector:
    app: mysql
  ports:
    - port: 3306
      targetPort: 3306
      nodePort: 32432
  type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
  namespace: sg-bs
  labels:
    app: mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      nodeSelector:
        kubernetes.io/hostname: sg-14
      containers:
        - name: mysql
          image: mysql:5.7
          volumeMounts:
            - mountPath: /etc/localtime
              name: time-zone
            - mountPath: /var/lib/mysql
              name: mysql-data
            - mountPath: /var/log/mysql
              name: mysql-logs
          ports:
            - containerPort: 3306
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: "xxxxxx" #密码
      volumes:
        - name: time-zone
          hostPath:
            path: /etc/localtime
        - name: mysql-data
          hostPath:
            path: /data/mysql-data
        - name: mysql-logs
          hostPath:
            path: /data/mysql-logs
posted @ 2022-11-02 11:35  Jeff的技术栈  阅读(61)  评论(0编辑  收藏  举报
回顶部