Hashicorp recommends installing Consul in Kubernetes through a Helm chart. Note that this may change in the future as Kubernetes Operators are being used to install and maintain the life cycle of the Kubernetes resources. To install Consul Helm for Kubernetes, follow these steps:
- Find the available versions of the Consul Helm for Kubernetes:
$ curl -L -s https://api.github.com/repos/hashicorp/consul-helm/tags | grep "name"
- Here, we're going to use version 0.11.0. You should download this version so that everything is consistent with the exercises in this chapter:
$ cd # switch to home dir
$ export CONSUL_HELM_VERSION=0.11.0
$ curl -LOs https://github.com/hashicorp/consul-helm/archive/v${CONSUL_HELM_VERSION}.tar.gz
$ tar xfz v${CONSUL_HELM_VERSION}.tar.gz
- In the Helm chart for Consul, we need to modify the failureThreshold and initialDelaySeconds parameters. Change the default values of 2 and 5 seconds to 30 and 60 seconds, respectively. This was necessary for the VMs since we are in a resource-constrained environment:
$ sed -i 's/failureThreshold:.*/failureThreshold: 30/g'
~/consul-helm-${CONSUL_HELM_VERSION}/templates/server-statefulset.yaml
$ sed -i 's/initialDelaySeconds:.*/initialDelaySeconds: 60/g'
~/consul-helm-${CONSUL_HELM_VERSION}/templates/server-statefulset.yaml
After making these changes, we can install Helm for Consul in Kubernetes.