Kubernetes https ingress

generate key and cert

openssl genrsa -out key.pem 2048
openssl req -new -x509 -key key.pem -out cert.pem -days 3650 -subj "/C=CN/ST=Liaoning/L=Dalian/O=test/OU=test/CN=test.com"
kubectl -n default create secret tls test-secret --key ./key.pem --cert ./cert.pem

create secrete

 kubectl create secret tls test-secret --key ./test.key --cert ./test.pem

create ingress.yaml and apply it 

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/backend-protocol: HTTP
    nginx.ingress.kubernetes.io/ssl-passthrough: "true"
  name: test
spec:
  rules:
  - host: test.com
    http:
      paths:
      - backend:
          serviceName: test
          servicePort: 80
        pathType: ImplementationSpecific
  tls:
  - hosts:
    - test.com
    secretName: test-secret

---END---

你可能感兴趣的:(Kubernetes)