Skip to content

Commit

Permalink
fix: Update installer.sh to use helm for cert-manager (#163)
Browse files Browse the repository at this point in the history
This updates the install script to use helm to install cert-manager. This makes the installer work both for
GKE Autopilot and non-autopilot clusters.

Fixes #157
  • Loading branch information
hessjcg authored Jan 11, 2023
1 parent 87ce4d4 commit 62fc5dc
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 38 deletions.
37 changes: 30 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,17 @@ update_image: kustomize # Update the image used in the kubernetes config to $(IM
deploy_with_kubeconfig: install_certmanager install_crd deploy_operator

.PHONY: install_certmanager
install_certmanager: kubectl # Install the cert-manager operator to manage the certificates for the operator webhooks
$(KUBECTL) apply -f "https://github.com/cert-manager/cert-manager/releases/download/$(CERT_MANAGER_VERSION)/cert-manager.yaml"
$(KUBECTL) rollout status deployment -n cloud-sql-proxy-operator-system cloud-sql-proxy-operator-controller-manager --timeout=90s
install_certmanager: helm # Install the cert-manager operator to manage the certificates for the operator webhooks
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm get all -n cert-manager cert-manager || \
helm install \
cert-manager jetstack/cert-manager \
--namespace cert-manager \
--version "$(CERT_MANAGER_VERSION)" \
--create-namespace \
--set global.leaderElection.namespace=cert-manager \
--set installCRDs=true

.PHONY: install_crd
install_crd: kustomize kubectl # Install CRDs into the K8s cluster using the kubectl default behavior
Expand Down Expand Up @@ -268,10 +276,18 @@ e2e_cluster_destroy: e2e_project terraform # Destroy the infrastructure for e2e
testinfra/run.sh destroy

.PHONY: e2e_cert_manager_deploy
e2e_cert_manager_deploy: e2e_project kubectl # Deploy the certificate manager
$(E2E_KUBECTL) apply -f https://github.com/cert-manager/cert-manager/releases/download/$(CERT_MANAGER_VERSION)/cert-manager.yaml
# wait for cert manager to become available before continuing
$(E2E_KUBECTL) rollout status deployment cert-manager -n cert-manager --timeout=90s
e2e_cert_manager_deploy: e2e_project helm # Deploy the certificate manager
helm repo add jetstack https://charts.jetstack.io --kubeconfig=$(KUBECONFIG_E2E)
helm repo update --kubeconfig=$(KUBECONFIG_E2E)
helm get all -n cert-manager cert-manager --kubeconfig=$(KUBECONFIG_E2E) || \
helm --kubeconfig=$(KUBECONFIG_E2E) install \
cert-manager jetstack/cert-manager \
--kubeconfig=$(KUBECONFIG_E2E) \
--namespace cert-manager \
--version "$(CERT_MANAGER_VERSION)" \
--create-namespace \
--set global.leaderElection.namespace=cert-manager \
--set installCRDs=true


.PHONY: e2e_install_crd
Expand Down Expand Up @@ -407,3 +423,10 @@ gcloud:
echo "Instructions on how to install https://cloud.google.com/sdk/docs/install " ; \
exit 1)

.PHONY: helm
helm:
@which helm > /dev/null || \
(echo "Helm command line tools are not available in your path" ; \
echo "Instructions on how to install https://helm.sh/docs/helm/helm_install/ " ; \
exit 1)

21 changes: 4 additions & 17 deletions docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,16 @@ Confirm that kubectl can connect to the cluster.
kubectl cluster-info
```

Install cert-manager using helm. Note that because you are using a GKE
Autopilot cluster, you need to use this particular version with these specific
cli arguments to make cert-manager work on your GKE Autopilot cluster.

```shell
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install \
cert-manager jetstack/cert-manager \
--namespace cert-manager \
--version "v1.9.1" \
--create-namespace \
--set global.leaderElection.namespace=cert-manager \
--set installCRDs=true
```

Run the following command to install the cloud sql proxy operator into
your kubernetes cluster:

```shell
curl https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy-operator/v0.1.0/cloud-sql-proxy-operator.yaml | bash
curl https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy-operator/v0.1.0/install.sh | bash
```

This will use `helm` to install the `cert-manager` operator, a prerequisite. Then
it will install the Cloud SQL Proxy Operator in your cluster.

Wait for the Cloud SQL Auth Proxy Operator to start.

```shell
Expand Down
36 changes: 29 additions & 7 deletions installer/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,46 @@

set -euxo # exit 1 from the script when command fails

VERSION="v0.1.1-dev"
CERT_MANAGER_VERSION="v1.9.1"
# If CSQL_OPERATOR_VERSION is not set, use the release version: v0.1.1-dev.
CSQL_OPERATOR_VERSION="${CSQL_OPERATOR_VERSION:-v0.1.1-dev}"

# If CSQL_CERT_MANAGER_VERSION is not set, use the default: v1.9.1.
CSQL_CERT_MANAGER_VERSION="${CSQL_CERT_MANAGER_VERSION:-v1.9.1}"

# If CSQL_OPERATOR_URL is not set, use the default value from the CSQL_OPERATOR_VERSION
CSQL_OPERATOR_URL="${CSQL_OPERATOR_URL:-https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy-operator/$CSQL_OPERATOR_VERSION/cloud-sql-proxy-operator.yaml}"

# Ensure kubectl exists
if ! which kubectl ; then
echo "kubectl, the kubernetes command line client, was not found in the PATH."
echo "See https://kubernetes.io/docs/tasks/tools/ for instructions on how to"
echo "install kubectl."
exit 1
fi

# Install cert-manager
kubectl apply -f "https://github.com/cert-manager/cert-manager/releases/download/$CERT_MANAGER_VERSION/cert-manager.yaml"
# Ensure helm exists
if ! which helm ; then
echo "helm, the installer for kubernetes applications, was not found in the PATH."
echo "See https://helm.sh/docs/intro/install/ for instructions on how to"
echo "install helm."
exit 1
fi

# Wait for cert-manager to become available before continuing
kubectl rollout status deployment cert-manager -n cert-manager --timeout=90s
# Install cert-manager using helm
if ! helm get all -n cert-manager cert-manager > /dev/null ; then
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install \
cert-manager jetstack/cert-manager \
--namespace cert-manager \
--version "$CSQL_CERT_MANAGER_VERSION" \
--create-namespace \
--set global.leaderElection.namespace=cert-manager \
--set installCRDs=true
fi

# Install the cloud-sql-proxy-operator
kubectl apply -f "https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy-operator-dev/$VERSION/cloud-sql-proxy-operator.yaml"
kubectl apply -f "$CSQL_OPERATOR_URL"

# Wait for cloud-sql-proxy-operator to become available
kubectl rollout status deployment -n cloud-sql-proxy-operator-system cloud-sql-proxy-operator-controller-manager --timeout=90s
36 changes: 29 additions & 7 deletions tools/install.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,46 @@

set -euxo # exit 1 from the script when command fails

VERSION="__VERSION__"
CERT_MANAGER_VERSION="__CERT_MANAGER_VERSION__"
# If CSQL_OPERATOR_VERSION is not set, use the release version: __VERSION__.
CSQL_OPERATOR_VERSION="${CSQL_OPERATOR_VERSION:-__VERSION__}"

# If CSQL_CERT_MANAGER_VERSION is not set, use the default: __CERT_MANAGER_VERSION__.
CSQL_CERT_MANAGER_VERSION="${CSQL_CERT_MANAGER_VERSION:-__CERT_MANAGER_VERSION__}"

# If CSQL_OPERATOR_URL is not set, use the default value from the CSQL_OPERATOR_VERSION
CSQL_OPERATOR_URL="${CSQL_OPERATOR_URL:-https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy-operator/$CSQL_OPERATOR_VERSION/cloud-sql-proxy-operator.yaml}"

# Ensure kubectl exists
if ! which kubectl ; then
echo "kubectl, the kubernetes command line client, was not found in the PATH."
echo "See https://kubernetes.io/docs/tasks/tools/ for instructions on how to"
echo "install kubectl."
exit 1
fi

# Install cert-manager
kubectl apply -f "https://github.com/cert-manager/cert-manager/releases/download/$CERT_MANAGER_VERSION/cert-manager.yaml"
# Ensure helm exists
if ! which helm ; then
echo "helm, the installer for kubernetes applications, was not found in the PATH."
echo "See https://helm.sh/docs/intro/install/ for instructions on how to"
echo "install helm."
exit 1
fi

# Wait for cert-manager to become available before continuing
kubectl rollout status deployment cert-manager -n cert-manager --timeout=90s
# Install cert-manager using helm
if ! helm get all -n cert-manager cert-manager > /dev/null ; then
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install \
cert-manager jetstack/cert-manager \
--namespace cert-manager \
--version "$CSQL_CERT_MANAGER_VERSION" \
--create-namespace \
--set global.leaderElection.namespace=cert-manager \
--set installCRDs=true
fi

# Install the cloud-sql-proxy-operator
kubectl apply -f "https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy-operator-dev/$VERSION/cloud-sql-proxy-operator.yaml"
kubectl apply -f "$CSQL_OPERATOR_URL"

# Wait for cloud-sql-proxy-operator to become available
kubectl rollout status deployment -n cloud-sql-proxy-operator-system cloud-sql-proxy-operator-controller-manager --timeout=90s

0 comments on commit 62fc5dc

Please sign in to comment.