Consul

Consul部署

Statefulset

apiVersion: apps/v1 
kind: StatefulSet
metadata:
  name: stag-consul
  namespace: monitoring
spec:
  serviceName: stag-consul
  selector:
    matchLabels:
      app: stag-consul
  replicas: 1
  template: 
    metadata:
      labels:
        app: stag-consul
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: consul
        image: consul:1.15.1
        args:
             - "agent"
             - "-server"
             - "-bootstrap-expect=1"
             - "-ui"
             - "-data-dir=/consul/data"
             - "-bind=0.0.0.0"
             - "-client=0.0.0.0"
             - "-advertise=$(PODIP)"
             - "-retry-join=stag-consul"
             - "-retry-join=stag-consul-0.stag-consul.$(NAMESPACE).svc.cluster.local"
             - "-domain=cluster.local"
             - "-disable-host-node-id"
        volumeMounts:
            - name: data
              mountPath: /consul/data
        env:
            - name: PODIP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
        ports:
            - containerPort: 8500
              name: ui-port
            - containerPort: 8400
              name: alt-port
            - containerPort: 53
              name: udp-port
            - containerPort: 8443
              name: https-port
            - containerPort: 8080
              name: http-port
            - containerPort: 8301
              name: serflan
            - containerPort: 8302
              name: serfwan
            - containerPort: 8600
              name: consuldns
            - containerPort: 8300
              name: server
  volumeClaimTemplates:
    - metadata:
        name: data
      spec:
        storageClassName: cbs-hdd
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: "10Gi"

Service

apiVersion: v1
kind: Service
metadata:  
    name: stag-consul  
    namespace: monitoring
    labels:    
      name: stag-consul
spec:  
    type: ClusterIP  
    ports:    
     - name: http      
       port: 8500      
       targetPort: 8500    
     - name: https      
       port: 8443      
       targetPort: 8443    
     - name: rpc      
       port: 8400      
       targetPort: 8400    
     - name: serflan-tcp      
       protocol: "TCP"      
       port: 8301      
       targetPort: 8301    
     - name: serflan-udp      
       protocol: "UDP"      
       port: 8301      
       targetPort: 8301    
     - name: serfwan-tcp      
       protocol: "TCP"      
       port: 8302      
       targetPort: 8302    
     - name: serfwan-udp      
       protocol: "UDP"      
       port: 8302      
       targetPort: 8302    
     - name: server      
       port: 8300      
       targetPort: 8300    
     - name: consuldns      
       port: 8600      
       targetPort: 8600  
    selector:    
      app: stag-consul
    clusterIP: None

Ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx-ingress-inside
    kubernetes.io/ingress.rule-mix: "true"
    kubernetes.io/ingress.subnetId: subnet-bkty3add
  generation: 1
  name: consul
  namespace: monitoring
spec:
  rules:
  - host: tencent.aaa.com
    http:
      paths:
      - backend:
          service:
            name: public-consul
            port:
              number: 8500
        path: /
        pathType: ImplementationSpecific
  tls:
  - hosts:
    - tencent.aaa.com
    secretName: paigod-work-2024-01-10
posted @ 2023-06-14 19:34  元气少女郭德纲!!  阅读(63)  评论(0编辑  收藏  举报