An nginx example application to be used with gitkube: git push to deploy on to Kubernetes.
-
Install gitkube on your Kubernetes cluster
$ kubectl create -f https://raw.githubusercontent.com/hasura/gitkube/master/manifests/gitkube-setup.yaml $ #expose gitkubed service $ kubectl --namespace kube-system expose deployment gitkubed --type=LoadBalancer --name=gitkubed
-
Clone this repo:
$ git clone https://github.com/hasura/gitkube-example $ cd gitkube-example
-
Create a kubernetes deployment and service:
$ kubectl create -f k8s.yaml
-
Add your SSH public key to
remote.yaml
:$ cat ~/.ssh/id_rsa.pub | awk '$0=" - "$0' >> "remote.yaml"
-
[Multi-node] If you are running a multi-node cluster,
remote.yaml
should specify aregistry
to push and pull from/into the cluster. Read more about this secret hereregistry: url: "registry.io/user" credentials: # dockercfg secret secretKeyRef: name: regsecret key: .dockercfg
-
Create the gitkube remote:
$ kubectl create -f remote.yaml
-
Wait for the remote url:
$ kubectl get remote example -o json | jq -r '.status.remoteUrl' # remoteUrl will be like ssh://example-default@[ip-address]/~/git/example-default
-
Create the git remote:
$ git remote add example [remoteUrl]
-
Git push to update the nginx application
$ git push example master
-
Checkout the application using kubectl proxy:
$ kubectl proxy
Visit http://localhost:8001/api/v1/namespaces/default/services/nginx/proxy on browser