给服务添加路由--ingress

kind: Namespace
apiVersion: v1
metadata:
  name: demo-webshell
  generateName: demo-webshell
  labels:
    name: demo-webshell
    purpose: Demonstration
  annotations:
    describe: Just show how to create
status:
  phase: ''
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: webshell-ingress
  namespace: demo-webshell
spec:
  rules:
  - host: webshell.com
    http:
      paths:
      - path: /
        backend:
          serviceName: webshell
          servicePort: 80
      - path: /ping
        backend:
          serviceName: webshell
          servicePort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: webshell
  namespace: demo-webshell
spec:
  type: ClusterIP
  ports:
  - name: webshell
    port: 80
    targetPort: 80
    protocol: TCP
  - name: ssh
    port: 22
    targetPort: 22
    protocol: TCP
  selector:
    app: webshell
---
apiVersion: v1
kind: Service
metadata:
  name: webshell-nodeport
  namespace: demo-webshell
spec:
  type: NodePort
  ports:
  - name: webshell
    port: 80
    targetPort: 80
    protocol: TCP
  - name: ssh
    port: 22
    targetPort: 22
    protocol: TCP
  selector:
    app: webshell
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: webshell
  namespace: demo-webshell
spec:
  replicas: 1
  selector:
    matchLabels:
      app: webshell
  template:
    metadata:
      labels:
        name: webshell
        app: webshell
    spec:
      containers:
      - name: webshell
        image: lijiaocn/webshell:1.0
        resources:
          limits:
            cpu: 3
            memory: 128Mi
          requests:
            cpu: 0.1
            memory: 32Mi
        livenessProbe:
          tcpSocket:
            port: 80
          initialDelaySeconds: 5
          timeoutSeconds: 5
          periodSeconds: 10
          successThreshold: 1
          failureThreshold: 3
        imagePullPolicy: Always
        securityContext:
          privileged: false
          runAsNonRoot: false
        stdin: false
        stdinOnce: false
        tty: false
      - name: sshproxy
        image: lijiaocn/sshproxy:1.0
        env:
        - name: ROOTPASS
          value: '123456'
        resources:
          limits:
            cpu: 3
            memory: 128Mi
          requests:
            cpu: 0.1
            memory: 32Mi
        livenessProbe:
          tcpSocket:
            port: 22
          initialDelaySeconds: 5
          timeoutSeconds: 5
        imagePullPolicy: Always
        securityContext:
          privileged: false
          runAsNonRoot: false
        stdin: false
        stdinOnce: false
        tty: false
      restartPolicy: Always
      dnsPolicy: Default
      serviceAccountName: default
      hostNetwork: false
      hostPID: false
      hostIPC: false

猜你喜欢

转载自www.cnblogs.com/justart/p/11950150.html