简体   繁体   中英

Kubernetes: How to use https communication between pods

I have two Pods and they are in the same kubernetes cluster and Pod1 should communicate Pod2 over https.

I use the internal Domainname: backend-srv.area.cluster.local But howto generate and integrate a cert to Pod2(apache)?

Your certificates should be generated and passed to apache by a Kubernetes Secret Resource

apiVersion: v1
kind: Secret
metadata:
  name: apache-secret
data:
  cacerts: your_super_long_string_with_certificate

In your pod yaml configuration you're going to use that secret:

 volumes:      
   - name: certs
     secret:
       secretName: apache-secret
       items:
       - key: cacerts
         path: cacerts

I suggest you to use a Service to connect to your pods:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: apache
  name: apache
spec:
  externalTrafficPolicy: Cluster
  ports:
  - name: apache
    port: 80
    targetPort: 80
    nodePort: 30080
  selector:
    app: apache
  type: NodePort

Make the proper adjustments to my examples.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM