YAML DEMO

有时候会用到避免重写,重找麻烦

1.busybox

apiVersion: apps/v1
kind: Deployment
metadata:
  name: client
spec:
  replicas: 1
  selector:
    matchLabels:
      app: client
  template:
    metadata:
      labels:
        app: client
    spec:
      containers:
      - name: busybox
        image: busybox:1.28.4
        imagePullPolicy: IfNotPresent
        command: ["/bin/sh","-c","sleep 3600"]

 command: ["/bin/sh","-c","echo 'hello httpd' > /var/www/index/html;httpd -f -p 8080 -h /var/www"] #开启httpd

2. nginx

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-test
  labels:
    app: nginx-test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx-test
  template:
    metadata:
      labels:
        app: nginx-test
    spec:
      containers:
      - name: nginx
        image: nginx
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-test
  labels:
    app: nginx-test
spec:
  ports:
  - name: nginx-test
    port: 80
    targetPort: 80
  selector:
    app: nginx-test

 

ingress

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  namespace: xxx
  name: nginx-test
spec:
  rules:
  - host: test.xxx.com 
    http:
      paths:
      - backend:
          serviceName: xxxx #svc name
          servicePort: xx   #svc port
        path: /
status:  ##没有loadBalancer 可以去掉
  loadBalancer:
    ingress:
      - ip: xx.xx.xx.xx

 

posted @ 2020-12-09 11:40  执酒  阅读(173)  评论(0编辑  收藏  举报