Creating a Helm Repo with Github

Next step in learning helm is being able to take an existing helm package and put it in your own repo.

There are ways to do this with github pages. I don’t really want mess withthat right now, how can I use a Github repo to host my changes to the deployment?

For installing helm and an additional demo please see part 1 of this series.

http://54.88.246.86/2018/03/27/getting-started-with-helm-for-k8s/

Create the package

The helm package commands take the files with the directory and puts them into a tgz file. This package is what will be used when we deploy the chart.

Second command I run is the helm repo index . This creates the index file that is used when adding and querying the repo. Without this file helm repo add will fail.

jowings@kube1:~/minecraft$ ls

Chart.yaml  index.yaml  minecraft-0.2.0.tgz  README.md  templates  values.yaml

jowings@kube1:~/minecraft$ helm repo index .

jowings@kube1:~/minecraft$ tree .

.

├── Chart.yaml

├── index.yaml

├── minecraft-0.2.0.tgz

├── README.md

├── templates

│   ├── datadir-pvc.yaml

│   ├── deployment.yaml

│   ├── _helpers.tpl

│   ├── minecraft-svc.yaml

│   ├── NOTES.txt

│   ├── rcon-svc.yaml

│   └── secrets.yaml

└── values.yaml

Push to GitHub

The next step is to push the changed files to github. This post doesn’t go over setting up github and creating a new repository.

jowings@kube1:~/minecraft$ git add .

jowings@kube1:~/minecraft$ git commit -m "new package"

[master 3905900] new package

2 files changed, 3 insertions(+), 3 deletions(-)

rewrite minecraft-0.2.0.tgz (99%)

jowings@kube1:~/minecraft$ git push

Username for 'https://github.com': 2vcps

Password for 'https://2vcps@github.com':

Counting objects: 4, done.

Delta compression using up to 4 threads.

Compressing objects: 100% (4/4), done.

Writing objects: 100% (4/4), 12.14 KiB | 0 bytes/s, done.

Total 4 (delta 2), reused 0 (delta 0)

remote: Resolving deltas: 100% (2/2), completed with 2 local objects.

To https://github.com/2vcps/helm-pure-mc.git

3c72998..3905900  master -> master

 

Add the Repo to Helm

First get the raw path where the index.yaml lives. Easily do this by click the index.yaml to view it, thing click raw on Github. Then do a helm repo add <url>

https://raw.githubusercontent.com/2vcps/helm-pure-mc/master/

jowings@kube1:~/minecraft$ helm repo add helm-pure-mc https://raw.githubusercontent.com/2vcps/helm-pure-mc/master/

"helm-pure-mc" has been added to your repositories

jowings@kube1:~/minecraft$ helm repo update

Hang tight while we grab the latest from your chart repositories...

...Skip local chart repository

...Successfully got an update from the "helm-pure-mc" chart repository

...Successfully got an update from the "jupyterhub" chart repository

...Successfully got an update from the "stable" chart repository

Update Complete. ? Happy Helming!?

Only grab the path!

Now Install using helm

In this step we are going to install the chart and test it out. helm install <path to chart> -n <name for release>

Note: Right now releases cannot have uppercase characters.

jowings@kube1:~/minecraft$ helm install helm-pure-mc/minecraft -n minecraftforthepeople

NAME:   minecraftforthepeople

LAST DEPLOYED: Wed Mar 28 06:12:44 2018

NAMESPACE: default

STATUS: DEPLOYED

RESOURCES:

==> v1/Secret

NAME                             TYPE    DATA  AGE

minecraftforthepeople-minecraft  Opaque  1     0s

==> v1/PersistentVolumeClaim

NAME                                     STATUS   VOLUME  CAPACITY  ACCESS MODES  STORAGECLASS  AGE

minecraftforthepeople-minecraft-datadir  Pending  pure    0s

==> v1/Service

NAME                             TYPE      CLUSTER-IP     EXTERNAL-IP  PORT(S)          AGE

minecraftforthepeople-minecraft  NodePort  10.111.136.14  <none>       25565:31812/TCP  0s

==> v1beta1/Deployment

NAME                             DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE

minecraftforthepeople-minecraft  1        1        1           0          0s

==> v1/Pod(related)

NAME                                              READY  STATUS             RESTARTS  AGE

minecraftforthepeople-minecraft-8689d4b76b-tx2tj  0/1    ContainerCreating  0         0s

 

NOTES:

Get the IP address of your Minecraft server by running these commands in the

same shell:

export NODE_PORT=$(kubectl get --namespace default \

-o jsonpath="{.spec.ports[0].nodePort}" services minecraftforthepeople-minecraft)

export NODE_IP=$(kubectl get nodes --namespace default \

-o jsonpath="{.items[0].status.addresses[0].address}")

echo "You'll need to expose this node through your security groups/firewall"

echo "for it to be world-accessible."

echo $NODE_IP:$NODE_PORT

jowings@kube1:~/minecraft$ export NODE_PORT=$(kubectl get --namespace default \

>     -o jsonpath="{.spec.ports[0].nodePort}" services minecraftforthepeople-minecraft)

jowings@kube1:~/minecraft$   export NODE_IP=$(kubectl get nodes --namespace default \

>     -o jsonpath="{.items[0].status.addresses[0].address}")

jowings@kube1:~/minecraft$   echo "You'll need to expose this node through your security groups/firewall"

You'll need to expose this node through your security groups/firewall

jowings@kube1:~/minecraft$   echo "for it to be world-accessible."

for it to be world-accessible.

jowings@kube1:~/minecraft$   echo $NODE_IP:$NODE_PORT

10.21.230.90:31812

 

Make Data

List Deployed Charts (aka Releases)

jowings@kube1:~$helm list

Run this command to see your deployed charts

Update the Release

So I modified my release. I can’t auto accpet the EULA. Legal teams cringe at that kind of thing.

Also maybe I want to change the image for my App, because it has the new code or something.

jowings@kube1:~$helm upgrade --set minecraft.Server.eula=true minecraftforthepeople helm-pure-mc/minecraft

Important thing to notice since I cannot mark the values.yaml file to always accept the EULA for each user, we have to override the defualt setting with the –set flag. In this case we are actively accepting the eula, this makes legal people happy. You may have other settings that need to be set per environment or some other reason.

Bring it Home

Concluding, we have taken an existing helm chart and modified it for our needs. Packaged it and pushed it to our github repo. Then we took that repo and added it to helm. Using helm we were able to deploy the application and upgrade it later. This moves us closer to the “cloud native” model for this application. Next post I am going to take an existing home grown application and package it in helm. At that point we will be able to let devs run test/qa then give that same code to prod operations team for the same deployment.

2 thoughts on “Creating a Helm Repo with Github”

  1. I stumbled upon your post looking to see how does one rinse and repeat?

    How do I update the next version of chart with changes, and pull the latest from github?

    1. If I understand correctly you push the update to the chart to github.
      Then in helm do a: ‘helm repo update’ to get helm to pull the new specs in the chart.

Leave a Reply

Your email address will not be published. Required fields are marked *