Last active
November 15, 2021 01:01
-
-
Save Vertiwell/1dde24a1c4071d1fde8b0028351ff0b7 to your computer and use it in GitHub Desktop.
longhorn-ext-access.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### Longhorn Dashboard | |
## Create SSL access to the Longhorn dashboard | |
## Set Variables: | |
# Get the Cert-Manager Issuer | |
ISSUER=$(kubectl get clusterissuer -o json | jq -r ".items[].metadata.name") | |
# Set a domain to use (needs to be real if you want to access this externally from the internet) | |
echo "Provide a domain to use (i.e: example.com):" | |
read DOMAIN | |
# Name of the application | |
APP=longhorn | |
# Namespace the application is in | |
NAMESPACE=longhorn-system | |
# Service we need to target to direct traffic to | |
SERVICE=longhorn-frontend | |
# The port the service uses | |
PORT=80 | |
# Create the Certificate (standard template against name.whatever.com your domain is) | |
printf "apiVersion: cert-manager.io/v1\nkind: Certificate\nmetadata:\n name: "$APP"-dashboard-cert\n namespace: "$NAMESPACE"\nspec:\n commonName: "$APP"."$DOMAIN"\n secretName: "$APP"-dashboard-cert\n dnsNames:\n - "$APP"."$DOMAIN"\n issuerRef:\n name: "$ISSUER"\n kind: ClusterIssuer" > $APP-dashboard-cert.yaml && kubectl apply -f $APP-dashboard-cert.yaml && \ | |
# Create the IngressRoute to direct traffic to your application | |
printf "apiVersion: traefik.containo.us/v1alpha1\nkind: IngressRoute\nmetadata:\n name: "$APP"-dashboard-ingress\n namespace: "$NAMESPACE"\nspec:\n entryPoints:\n - websecure\n routes:\n - match: Host(\`"$APP"."$DOMAIN"\`) && PathPrefix(\`/\`)\n kind: Rule\n services:\n - name: "$SERVICE"\n port: "$PORT"\n tls:\n secretName: "$APP"-dashboard-cert" > $APP-dashboard-ingress.yaml && kubectl apply -f $APP-dashboard-ingress.yaml && \ | |
# Cleanup | |
rm $APP-dashboard* && \ | |
# Provide the user the URL | |
echo "URL is https://longhorn.$DOMAIN.com/#/dashboard" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment