-
-
Save vfarcic/a701b929d1416b095bd58daa24f8b013 to your computer and use it in GitHub Desktop.
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
############################################################### | |
# Using Rancher For Creating And Managing Kubernetes Clusters # | |
# https://youtu.be/LK6KbAlQRIg # | |
############################################################### | |
######### | |
# Setup # | |
######### | |
# Create a Kubernetes cluster with NGINX Ingress | |
kubectl apply --validate=false \ | |
--filename https://github.com/jetstack/cert-manager/releases/download/v1.0.4/cert-manager.crds.yaml | |
helm repo add jetstack \ | |
https://charts.jetstack.io | |
helm repo update | |
helm install \ | |
cert-manager jetstack/cert-manager \ | |
--create-namespace \ | |
--namespace cert-manager \ | |
--version v1.0.4 \ | |
--wait | |
# Replace `[...]` with your email | |
export EMAIL=[...] | |
# If NOT EKS | |
export INGRESS_HOST=$(kubectl \ | |
--namespace ingress-nginx \ | |
get svc ingress-nginx-controller \ | |
--output jsonpath="{.status.loadBalancer.ingress[0].ip}") | |
# If EKS | |
export INGRESS_HOSTNAME=$(kubectl \ | |
--namespace ingress-nginx \ | |
get svc ingress-nginx-controller \ | |
--output jsonpath="{.status.loadBalancer.ingress[0].hostname}") | |
# If EKS | |
export INGRESS_HOST=$(\ | |
dig +short $INGRESS_HOSTNAME) | |
echo $INGRESS_HOST | |
# Repeat the `export` commands if the output is empty | |
# If the output contains more than one IP, wait for a while longer, and repeat the `export` commands. | |
# If the output continues having more than one IP, choose one of them and execute `export INGRESS_HOST=[...]` with `[...]` being the selected IP. | |
export RANCHER_ADDR=rancher.$INGRESS_HOST.nip.io | |
################################################## | |
# Installing Rancher inside a Kubernetes cluster # | |
################################################## | |
helm repo add rancher \ | |
https://releases.rancher.com/server-charts/stable | |
helm repo update | |
helm upgrade --install \ | |
rancher rancher/rancher \ | |
--namespace cattle-system \ | |
--create-namespace \ | |
--set hostname=$RANCHER_ADDR \ | |
--set ingress.tls.source=letsEncrypt \ | |
--set letsEncrypt.email=$EMAIL \ | |
--wait | |
echo https://$RANCHER_ADDR | |
# Open it in your favorite browser | |
############################# | |
# Exploring the new cluster # | |
############################# | |
# Copy Kube config | |
# Feel free to use any other editor to create and open kubeconfig.yaml | |
vim kubeconfig.yaml | |
# Paste Kube config | |
export KUBECONFIG=$PWD/kubeconfig.yaml | |
kubectl get nodes | |
kubectl get services -A | |
kubectl get storageclasses | |
# Replace `[...]` with your DigitalOcean Token | |
export DO_TOKEN=[...] | |
echo "apiVersion: v1 | |
kind: Secret | |
metadata: | |
name: digitalocean | |
namespace: kube-system | |
stringData: | |
access-token: \"$DO_TOKEN\"" \ | |
| kubectl apply --filename - | |
kubectl apply \ | |
--filename https://raw.githubusercontent.com/digitalocean/csi-digitalocean/master/deploy/kubernetes/releases/csi-digitalocean-v2.1.1/crds.yaml | |
kubectl apply \ | |
--filename https://raw.githubusercontent.com/digitalocean/csi-digitalocean/master/deploy/kubernetes/releases/csi-digitalocean-v2.1.1/driver.yaml | |
kubectl apply \ | |
--filename https://raw.githubusercontent.com/digitalocean/csi-digitalocean/master/deploy/kubernetes/releases/csi-digitalocean-v2.1.1/snapshot-controller.yaml | |
kubectl get crds | grep scale |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment