Skip to content

Instantly share code, notes, and snippets.

@CJavierSaldana
Last active March 22, 2023 00:45
Show Gist options
  • Select an option

  • Save CJavierSaldana/f82b33c64d66f48489b56a78b39552d9 to your computer and use it in GitHub Desktop.

Select an option

Save CJavierSaldana/f82b33c64d66f48489b56a78b39552d9 to your computer and use it in GitHub Desktop.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: dashboard-ingress
namespace: kubernetes-dashboard
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
spec:
tls:
- hosts:
- dashboard.localdev.me
secretName: localdev-tls
rules:
- host: dashboard.localdev.me
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: kubernetes-dashboard
port:
number: 443
# Run this script to install the ingress controller
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.6.4/deploy/static/provider/cloud/deploy.yaml
# Run this script to create a certificate
openssl req -x509 -newkey rsa:4096 -keyout new-kube.key -out new-kube.cert -days 365 -nodes -subj "/CN=localdev.me" -extensions SAN -config <(printf "[req]\ndistinguished_name=req\n[SAN]\nsubjectAltName=DNS:localdev.me,DNS:*.localdev.me\n[req]\ndistinguished_name=req")
# Run this script to create a secret
# set the namespace to the namespace you want to use
# you need to create the secret in the same namespace as the ingress controller
kubectl create secret tls localdev-tls --namespace kubernetes-dashboard --key new-kube.key --cert new-kube.cert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment