Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Last active November 28, 2023 10:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save vfarcic/851b713d66bee8e90dba76c6dbb1c004 to your computer and use it in GitHub Desktop.
Save vfarcic/851b713d66bee8e90dba76c6dbb1c004 to your computer and use it in GitHub Desktop.
# Source: https://gist.github.com/851b713d66bee8e90dba76c6dbb1c004
#############################################################
# Tanzu Kuberentes Platform By VMware - Review And Tutorial #
# https://youtu.be/iO6ZLCrN8kA #
#############################################################
# Additional Info:
# - https://tanzucommunityedition.io
# - How To Manage Production-Grade Kubernetes Clusters With Rancher: https://youtu.be/JFALdhtBxR8
# - How To Create, Provision, And Operate Kubernetes With Cluster API (CAPI): https://youtu.be/8yUDUhZ6ako
# - Octant: Kubernetes Dashboard That Shouldn't Exist: https://youtu.be/HQ5FzDAz4X8
#########
# Setup #
#########
# Install `octant` using the instructions from https://reference.octant.dev/?path=/docs/docs-intro--page#getting-started
# Install `tanzu` using the instructions from https://tanzucommunityedition.io/docs/getting-started
# Follow the instructions from the output.
# Make sure that Docker is up-and-running
#################################################
# Create A Management Cluster With VMware Tanzu #
#################################################
tanzu management-cluster create --ui
# Create a management cluster in Docker
tanzu management-cluster get
# Replace `[...]` with the name of the management cluster
export MGMT_NAME=[...]
docker container ls -a
tanzu management-cluster kubeconfig \
get $MGMT_NAME \
--export-file kubeconfig-mgmt.yaml \
--admin
export KUBECONFIG=$PWD/kubeconfig-mgmt.yaml
kubectl get nodes
kubectl get namespaces
##############################################
# Create Workload Clusters With VMware Tanzu #
##############################################
ls -1 ~/.config/tanzu/tkg/clusterconfigs/
# Replace `[...]` with the name of the management cluster config file
export MGMT_CONFIG=[...]
cp ~/.config/tanzu/tkg/clusterconfigs/$MGMT_CONFIG \
~/.config/tanzu/tkg/clusterconfigs/app-cluster.yaml
# Open `~/.config/tanzu/tkg/clusterconfigs/app-cluster.yaml` in an editor
# Change `CLUSTER_NAME` value to `app-cluster`
# Save the changes
tanzu cluster create app-cluster \
--file ~/.config/tanzu/tkg/clusterconfigs/app-cluster.yaml
# Show AWS resources
tanzu cluster list
tanzu cluster list \
--include-management-cluster
kubectl get clusters.cluster.x-k8s.io
tanzu cluster kubeconfig \
get app-cluster \
--export-file kubeconfig-app.yaml \
--admin
export KUBECONFIG=$PWD/kubeconfig-app.yaml
kubectl get nodes
######################################
# Install Packages With VMware Tanzu #
######################################
tanzu package repository add tce-repo \
--url projects.registry.vmware.com/tce/main:0.11.0 \
--namespace tanzu-package-repo-global
tanzu package repository list \
--namespace tanzu-package-repo-global
tanzu package available list
tanzu package available list \
grafana.community.tanzu.vmware.com
# Open https://github.com/grafana/grafana/releases
# Open https://github.com/vmware-tanzu/community-edition
tanzu package install grafana \
--package-name grafana.community.tanzu.vmware.com \
--version 7.5.11
####################################
# Kubernetes Dashboard With Octant #
####################################
octant
#################################################
# Update And Upgrade Clusters With VMware Tanzu #
#################################################
# Open `~/.config/tanzu/tkg/clusterconfigs/app-cluster.yaml` in an editor
# Add `ENABLE_AUTOSCALER: true`
# Add `AUTOSCALER_MIN_SIZE_0: 2`
# Add `AUTOSCALER_MAX_SIZE_0: 5`
tanzu cluster --help
tanzu cluster upgrade app-cluster
kubectl get nodes
kubectl get nodes \
--kubeconfig kubeconfig-mgmt.yaml
###########
# Destroy #
###########
tanzu cluster delete app-cluster
# Change `[...]` to the region where the management cluster is running (e.g., `us-east-1`)
export AWS_REGION=[...]
tanzu management-cluster delete $MGMT_NAME
rm ~/.config/tanzu/tkg/clusterconfigs/*.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment