Giter Club home page Giter Club logo

github-page-helm-deployer's Introduction

README:

A helm deployer to github page helm repository.

Unlike DockerHub we do not have a cloud HelmHub accessible to everyone. Only this is available: https://hub.helm.sh/charts

But we can turn Github page to a private HelmHub as explained here: https://helm.sh/docs/topics/chart_repository/#github-pages-example

Objective of this project is to deploy helm chart present in a github repository automatically to this helm chart repository using Travis CI/CD. An example is given in this readme here.

Note the Helm repository using Github page could be replaced by a Jfrog artifactory.

User guide

Prerequisite 1: Repo creation

Github page basics

We will turn github page feature to an helm registry. This repo will be our helm repository/artifactory.

From: https://docs.github.com/en/github/working-with-github-pages/about-github-pages#types-of-github-pages-sites

There are three types of GitHub Pages sites: project, user, and organization.

  1. we can create repo inside an orga such as:
    • a helm-registry.github.io within organization helm-registry. we can access to it via helm-registry.github.io. It is an organisation page.
    • b helm-registrywithin organizationhelm-registry. we can access to it via helm-registry.github.io/helm-registry. It is a project page.
  2. Or create a user repo
    • a scoulomb.github.io within username scoulomb. we can access to it via scoulomb.github.io. It is usually allocated for user personal page. It is a user page.
    • b helm-registry within username scoulomb. we can access to it via scoulomb.github.io/helm-registry It is a project page.

Note repo xxxx.github.io is limited to 1 per orga/username. A user can be part/own of several organisations. We can also do actually a la project access for 1a and 2a:

  • helm-registry.github.io/helm-registry.github.io
  • scoulomb.github.io/scoulomb.github.io

A user repo has the same behavior as orga repo when it comes to github page.

As explained in githb page and DNS, I recomend option 1a, for better DNS definition.

Operations

In this repo we will perform a git init by adding at least a readme or html index. Note adding empty ready can be performed via the UI (create file) or at repo creation time. Then will activate github page for naster branch at /root level (not /doc).

Prerequisite 2: Generate a github token

> settings> developer settings > Personal access tokens, or use this direct [link]( github repo which will be our helm repository/artifactory):

  • Generate new token
  • Tick on select scope: repo
  • Copy your token, for instance 1423a52e3fb0343f4f4f45157d9328d9065f6a72.

Run from docker or docker-compose

For instance using

Docker

➤ docker run scoulomb/github-page-helm-deployer -h                       
usage: ./deliver_helm.sh [-h] --chart <chart-path> --repo <helm-repo> --project <helm-project-name> --url <helm-registry-public-url> --token <github-token>
A script to push helm chart to github helm chart repository. As a prerequisite crate a github repo with readme from the UI and activate github page (master, /root). Check committer name.
Arguments
   -c, --chart         Path to the helm chart to be delivered
   -r, --repo:         Your helm chart github repository <username or organization name>/<repository name>
   -p, --project       Project to update within your helm chart github repository
   -u, --url           URL to the helm registry
   -t, -token          Github token for registry access

Example: See readme at https://github.com/scoulomb/github-page-helm-deployer
docker run -v "/home/vagrant/dev/soapUI-docker/kubernetes_integration_example/helm-k8s-integration:/tmp/helm-chart" \
scoulomb/github-page-helm-deployer \
-c /tmp/helm-chart \
-r helm-registry/helm-registry.github.io \
-p soapui \
-u helm-registry.github.io \
-t 1423a52e3fb0343f4f4f45157d9328d9065f6a72 

Delivered compose

export TOKEN="<your-token>"
docker-compose -f docker-compose-delivered.yaml up

TOKEN is an environment taken by compose file. It is useful for CI/CD pipeline integration.

CI CD pipeline with travis

You may want to deliver a new helmchart in helmhub at each delivery of your code. This is possible via this image and modifying previous docker-compose.

For instance we will use this project.

it is taking an environment var TOKEN, let's define it in Travis. https://travis-ci.com/github/scoulomb/soapui-docker/settings

Usage of helm registry once helm deliverable are pushed

sudo minikube start --vm-driver=none
sudo su # Otherwise given kubectl config will not target minikube (but cluster in vagrant kubeconfig, like the one setup by OpenShift)
# See for more details: https://github.com/scoulomb/myk8s/blob/master/Master-Kubectl/kube-config.md
# if user project do instead: helm repo add soapui https://scoulomb.github.io/helm-registry/soapui
helm repo add soapui https://helm-registry.github.io/helm-registry.github.io/soapui
# See it is updated
helm search repo soapui # should see last pushed version
helm uninstall test-helm-k8s-integration 
# https://github.com/scoulomb/soapui-docker/blob/master/kubernetes_integration_example/helm-k8s-integration/values.yaml
helm install test-helm-k8s-integration soapui/helm-k8s-integration  --set args.sender="[email protected]" --set args.recipient="[email protected]" --set args.password="<the-password-of-gmail-account>"
watch kubectl get cj

We can also do cf explanation at the beginning:

helm repo add soapui https://helm-registry.github.io/soapui (orga site, though it can be accessible as a project)

And since we define a CNAME for helm.registry.coulombel.site in appendix github page and DNS. We can do:

helm repo add soapui https://helm.registry.coulombel.site/soapui 

Output is

➤ helm repo add soapui https://helm.registry.coulombel.site/soapui                                                                                                         
"soapui" has been added to your repositories

However some network may block the helm.registry.coulombel.site or helm-registry.github.io (as it redirects to helm.registry.coulombel.site due to custom DNS of github page). So helm repo add is working (index.yaml) but helm installis not able to fetch the helm package astar.gz` could be blocked from coulombel.site.

Otherwise it is working perfectly fine, when allowed. But for this reason I decided to disable custom DNS: https://github.com/helm-registry/helm-registry.github.io/settings here: "registry.coulombel.site". And it will break the resolution flow.

Dev guide

Script without docker

Needs helm and git on machine

./deliver_helm.sh \
-c /home/vagrant/dev/soapUI-docker/kubernetes_integration_example/helm-k8s-integration \
-r helm-registry/helm-registry.github.io \
-p soapui \
-u helm-registry.github.io \
-t 1423a52e3fb0343f4f4f45157d9328d9065f6a72

For 2b (if using user project repo) we would do instead, -r scoulomb/helm-registry -u scoulomb.github.io/helm-registry

Note the full URL path as it is a project repo as explained in repo creation.

Script with docker

docker build . -t github-page-helm-deployer
# https://docs.docker.com/engine/reference/commandline/run/
docker run github-page-helm-deployer -h
docker run -v "/home/vagrant/dev/soapUI-docker/kubernetes_integration_example/helm-k8s-integration:/tmp/helm-chart" \
github-page-helm-deployer \
-c /tmp/helm-chart \
-r helm-registry/helm-registry.github.io \
-p soapui \
-u helm-registry.github.io \
-t 1423a52e3fb0343f4f4f45157d9328d9065f6a72                        

Script with docker-compose

Adapt docker-compose file.

export TOKEN="<your-token>"
docker-compose up --build

Automatic delivery of deployer

At each master branch merge, a new deployer is released on docker-hub here: https://hub.docker.com/repository/docker/scoulomb/github-page-helm-deployer

Those images are used in user-guide which can be seen as the next section of this guide.

Links

github-page-helm-deployer's People

Contributors

scoulomb avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.