Skip to content

Google Cloud: Deploying via Helm

Paul Danelli edited this page Mar 2, 2022 · 5 revisions

Please Note: This is a UbiquityPress focused Wiki entry and does not apply to the Open Source Hyku Addons project

Deploying via Helm

To build a new version of the application please refer to the HykuAddons: Building a new release for deployment article.

TL;DR

If everything is already configured and you're already connected to the correct cluster and region:

helm repo update; 
helm upgrade hyku ubiquity-charts-hyku/hyku

Install Helm

https://helm.sh/docs/intro/install/

List releases

Start by using the helm list command to show the available releases.

~ ❯ helm list
NAME        	NAMESPACE	REVISION	UPDATED                                	STATUS  	CHART            	APP VERSION
# ...    
hyku        	default  	30      	2021-04-10 12:50:13.681628524 +0100 BST	deployed	hyku-4.0.1       	2.1.0-194  
# ... 

If you see an error similar to the following, you may need to reauthorise GCloud:

Error: Kubernetes cluster unreachable: Get "https://xxx.xxx.xxx.xx/version?timeout=32s": error executing access token command "/snap/google-cloud-sdk/174/bin/gcloud config config-helper --format=json": err=fork/exec /snap/google-cloud-sdk/174/bin/gcloud: no such file or directory output= stderr=

Reauthorise GCloud

Check that kubectl is authorised to read from the Hyku Addons cluster by using the kubectl get pods command.

If you see the following error, then you know you need to reauthorise your sesssion:

~ ❯ kubectl get pods
Unable to connect to the server: error executing access token command "/snap/google-cloud-sdk/174/bin/gcloud config config-helper --format=json": err=fork/exec /snap/google-cloud-sdk/174/bin/gcloud: no such file or directory output= stderr=

When kubectl works as exepected you should be able to use the helm list command and continue:

~ ❯ kubectl get pods
NAME                                                  READY   STATUS    RESTARTS   AGE
# ...
hyku-66d7c77bdc-2b7sn                                 1/1     Running   0          10h
hyku-66d7c77bdc-8stzr                                 1/1     Running   0          10h
hyku-66d7c77bdc-pz68n                                 1/1     Running   0          45h
hyku-66d7c77bdc-r4mc6                                 1/1     Running   0          45h
# ...


~ ❯ helm list
NAME        	NAMESPACE	REVISION	UPDATED                                	STATUS  	CHART            	APP VERSION
# ...    
hyku        	default  	30      	2021-04-10 12:50:13.681628524 +0100 BST	deployed	hyku-4.0.1       	2.1.0-194  
# ... 

Adding the Hyku Helm Repository

Hyku Addons helm chart is stored in a seperate private repository, so much be added to your helm configuration manually before you can deploy.

First, search to ensure it has not yet been added:

~ ❯ helm search repo hyku
Error: no repositories configured

Like apt and other package managers you must add the repository before you can add the Helm chart.

~ ❯ helm repo add ubiquity-charts-hyku gs://helm-charts-hyku
"ubiquity-charts-hyku" has been added to your repositories

If you receive Error: could not find protocol handler for: gs, then you will need to add the GS protocol via a plugin for Helm.

Installing GS Protocol

~ ❯ helm plugin install https://github.com/hayorov/helm-gcs.git --version 0.3.9

Then you will need to reauthorise your GCloud account:

~ ❯ gcloud auth application-default login

Add the repository:

helm repo add ubiquity-charts-hyku gs://helm-charts-hyku

Now confirm that the repository was added successfully:

~ ❯ helm repo list
NAME                	URL                  
ubiquity-charts-hyku	gs://helm-charts-hyku

Updating and deploying

Before you can deploy the application you will need to update the repository, much as you would with apt or brew.

~ ❯ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "ubiquity-charts-hyku" chart repository
Update Complete. ⎈Happy Helming!⎈

Now you should be able to search for the Hyku repository and see the current App version.

~ ❯ helm search repo hyku
NAME                       	CHART VERSION	APP VERSION	DESCRIPTION                                     
ubiquity-charts-hyku/hyku  	4.0.1        	2.1.0-194  	Hyku repository                                 
ubiquity-charts-hyku/tenant	0.0.3        	2.5.68     	Ubiquity Press repository tenant (with frontend)

Run the following to trigger the currently build version to be deployed:

~ ❯ helm upgrade hyku ubiquity-charts-hyku/hyku

Tenant Import Works

Tenants have their own specialised import workers, to avoid a scenario whereby a large import negatively affects the performance of the user facing Hyku workers. If you have upgraded a cluster, you will also have to upgrade the import workers or recent changes to the codebase may not be available.

To check which release the node is currently using, you can use describe:

kubectl describe deployments demo-import-workers | grep Image
# => Image:      eu.gcr.io/hyku-ucw/hyku:2.1.0-400

Normally, to update the Hyku node, you use the following:

# Update the chart
helm repo update; helm upgrade hyku ubiquity-charts-hyku/hyku

The import workers however, are not upgraded with this command. This is because the hyku Helm chart contains only the "hyku" and "workers" deployments, so the helm upgrade hyku #... command, specifies that only "hyku" should be updated.

To update a tenants import workers, which are labelled "<tenant_name>-import-workers", to the latest release:

# helm upgrade <tenant_name> ubiquity-charts-hyku/tenant

# So, to update the "demo" tenant
helm upgrade demo ubiquity-charts-hyku/tenant

To confirm it worked, run the describe command again:

kubectl describe deployments demo-import-workers | grep Image
# => Image:      eu.gcr.io/hyku-ucw/hyku:2.1.0-401

Please note: this will also upgrade the frontend codebase, so you should confirm that this is ok with Rees before proceeding.

Upgrading all tenants

If you wish to upgrade all of the import workers, you will have to manually run the upgrade command for each tenant. This means you need to know the name of each of the tenants in order to pass it to the upgrade command. This can be done by calling kubectl describe deployments without passing anything else. You will see a list of details for each of the nodes, including the import workers, and other services that you dont need to worry about.

In order to make it a little easier to parse, you can run the following command:

kubectl describe deployments | grep ^Name: | grep -v [-] | awk '{ print $NF }'

This will look for just the name of the node and ignore any with hyphenated names like "demo-import-workers".

anschutz
anschutzdemo
edemo
fcrepo
hyku
ltuscdemo
nsuoklib
nsuoklibdemo
pacific
pacificdemo
redlands
redlandsdemo
una
unademo
workers

As you can see from this list, there are a number that you do not need to worry about, like "fcrepo", "workers", "hyku". You will have to parse out the ones you are not interested from the list.

Helm Notes

You can use helm get notes hyku to get the default super admin password for the cluster you are connected to.

Set the cluster

To list all our deployments for the cluster where your images are stored - we are using the US cluster as an example:

gcloud config configurations activate ubiquityrepo-us;
gcloud container clusters get-credentials cluster-us --zone us-central1-a

Run the command to show current deployments:

kubectl get deployments

This should return you a table of current deployment:

NAME                                 READY   UP-TO-DATE   AVAILABLE   AGE
fcrepo                               1/1     1            1           119d
hyku                                 4/4     4            4           119d
mailgun-operator                     1/1     1            1           120d
pacific                              2/2     2            2           86d
pacificdemo                          2/2     2            2           118d
workers                              2/2     2            2           119d

In this list you can see hyku and workers. These two belong to the Hyku Helm chart and will be updated when you run helm upgrade hyku. However, this list also contains some specialised tenant workers, such as anschutzdemo-import-workers.

Check the deployed release

TL;DR

Get the current build version for the container:

kubectl describe deployments hyku | grep Image

Details

To see which build versions each of these pods is current running:

kubectl describe deployments workers

You will see a complete description of the deployment, containing the Image version, similar to this:

Image:      eu.gcr.io/hyku-ucw/hyku:2.1.0-288

However, if you look at the specialised tenant import worker pods:

kubectl describe deployments anschutzdemo-import-workers

You may well see a different image version in use:

Image:      eu.gcr.io/hyku-ucw/hyku:2.1.0-285
Clone this wiki locally