After satisfying all of the requirements that are listed in the README file for this repository, you are ready to begin.
Create a file that contains the authentication variable values to use at script invocation. Store the file outside of this repository, for example in $HOME/.vsphere_creds.env
. Protect that file with vSphere/vCenter credentials so that only you have Read access to it.
NOTE: Do not surround the values in the file with quotation marks, and make sure to avoid any trailing blank spaces.
Now each time you invoke the script, export the variables within the file to pass the credentials to it. You can run export $(grep -v '^#' ~/.vsphere_creds.env | xargs)
to export them all at once.
An example of this file can be found in the examples
directory here.
Create a file that contains the authentication variable values to use at script invocation. Store the file outside of this repository, for example in $HOME/.bare_metal_creds.env
. Protect that file with operating-system credentials so that only you have Read access to it
NOTE: Do not surround the values in the file with quotation marks, and make sure to avoid any trailing blank spaces.
Now each time you invoke the script, export the variables within the file to pass the credentials to it. You can run export $(grep -v '^#' ~/.bare_metal_creds.env | xargs)
to export them all at once.
An example of this file can be found in the examples
directory here.
Prepare your terraform.tfvars
file, as described in Customize Input Values.
This script offers options for both vSphere/vCenter and physical machines. Each section below describes what is needed for each option.
The script has the following options. These options include both actions for infrastructure and cluster creation along with encapsulated tooling.
Usage: ./oss-k8s.sh [apply|setup|install|update|uninstall|cleanup|destroy|helm|k|tf]
Actions - Items and Their Meanings
apply - IaC creation : vSphere/vCenter
setup - System and software setup : systems
install - Kubernetes install : systems
update - System and/or Kubernetes updates : systems
uninstall - Kubernetes uninstall : systems
cleanup - Systems and software cleanup : systems
destroy - IaC destruction : vSphere/vCenter
Action groupings - These items can be run together.
Alternate combinations are not allowed.
creation items - [apply setup install]
update items - [update]
destruction items - [uninstall cleanup destroy]
Toolset - Integrated tools
helm - Helm : Kubernetes
k - kubectl : Kubernetes
tf - Terraform : vSphere/vCenter
To create your system resources, run the oss-k8s.sh script with the apply setup install
command:
./oss-k8s.sh apply setup install
This command can take a few minutes to complete. Once complete, Terraform output values are written to the console. The inventory
file, the ansible-vars.yaml
and the kubeconfig
file for the cluster stored here [prefix]-oss-kubeconfig.conf
are written in the current directory, $(pwd)
.
To create your Kubernetes cluster, run the oss-k8s.sh script with the setup install
option:
./oss-k8s.sh setup install
When your resources have been created using the oss-k8s.sh
command, you can display Terraform output values by running the oss-k8s.sh script with the tf
option:
./oss-k8s.sh tf output -state /workspace/terraform.tfstate
To display complex or hidden items in the output, pass those values to the output
command:
./oss-k8s.sh tf output postgres_servers
NOTE: The -state
flag is only optional if the terraform.tfstate
file is not in the current directory.
To destroy all the resources that were created with the previous commands, run the using the oss-k8s.sh script destroy
command.
./oss-k8s.sh destroy
NOTE: The 'destroy' action is irreversible.
Following the steps in Running the Configuration Script writes the kube_config output value to a file, ./[prefix]-oss-kubeconfig.conf
. When the Kubernetes cluster is ready, use kubectl to interact with the cluster.
In order to run the kubectl
command with the oss-k8s.sh script to list cluster nodes, be sure to set your KUBECONFIG
environment variable so that it references the kubeconfig file that was created for your cluster. This example shows how you can get node information:
./oss-k8s.sh k get nodes -o wide