Giter Club home page Giter Club logo

terraform-vsphere-k0s's Introduction

About

Lint

An example k0s Kubernetes cluster in vSphere Debian Virtual Machines using terraform.

Usage (Ubuntu 22.04 host)

Create and install the base Debian 12 vagrant box.

Install Terraform:

wget https://releases.hashicorp.com/terraform/1.5.7/terraform_1.5.7_linux_amd64.zip
unzip terraform_1.5.7_linux_amd64.zip
sudo install terraform /usr/local/bin
rm terraform terraform_*_linux_amd64.zip

Save your environment details as a script that sets the terraform variables from environment variables, e.g.:

cat >secrets.sh <<'EOF'
export TF_VAR_prefix='k0s'
export TF_VAR_vsphere_user='[email protected]'
export TF_VAR_vsphere_password='password'
export TF_VAR_vsphere_server='vsphere.local'
export TF_VAR_vsphere_datacenter='Datacenter'
export TF_VAR_vsphere_compute_cluster='Cluster'
export TF_VAR_vsphere_datastore='Datastore'
export TF_VAR_vsphere_network='VM Network'
export TF_VAR_vsphere_folder='k0s'
export TF_VAR_vsphere_k0s_template='vagrant-templates/debian-12-amd64'
export GOVC_INSECURE='1'
export GOVC_URL="https://$TF_VAR_vsphere_server/sdk"
export GOVC_USERNAME="$TF_VAR_vsphere_user"
export GOVC_PASSWORD="$TF_VAR_vsphere_password"
EOF

NB You could also add these variables definitions into the terraform.tfvars file, but I find the environment variables more versatile as they can also be used from other tools, like govc.

Create the infrastructure:

rm -f ~/.ssh/known_hosts*
terraform init
TF_LOG=TRACE TF_LOG_PATH=terraform-plan.log terraform plan -out=tfplan
TF_LOG=TRACE TF_LOG_PATH=terraform-apply.log time terraform apply tfplan

Show information about kubernetes:

terraform output --raw kubeconfig >kubeconfig.yml
export KUBECONFIG="$PWD/kubeconfig.yml"
kubectl version --output yaml
kubectl cluster-info
kubectl get nodes -o wide
kubectl api-versions
kubectl api-resources -o wide
kubectl get namespaces
kubectl get all --all-namespaces -o wide
kubectl get events --all-namespaces --sort-by=.metadata.creationTimestamp
kubectl get charts --all-namespaces # aka charts.helm.k0sproject.io

Destroy the infrastructure:

time terraform destroy -auto-approve

terraform-vsphere-k0s's People

Contributors

rgl avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.