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://storage.googleapis.com/gitkube/gitkube-setup-stable.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 here and detailed instructions for few registry providers here.registry: url: "docker.io/<user>" credentials: # docker-registry secret name secretRef: regsecret
-
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://default-example@[ip-address]/~/git/default-example
Note that for services exposed as type NodePort,
remoteUrl
will not be filled automatically. Check.status.remoteUrlDesc
for instructions on manually constructing theremoteUrl
-
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