I have included a .env, ingress-nginx.yaml, controller-nginx.yaml, and bash script that will build your cluster and deploys everything in your folder you specifify in the parameter for the bash script parameters
To deploy from your cloud-config/staging folder and create the cluster do this:
./deploy.sh staging y
If you want to upgrade your existing app deployment, simply remove the y
./deploy.sh staging
gcloud config set project kube-tutorial
gcloud compute zones list
gcloud config set compute/zone us-east1-b
gcloud config set compute/region us-east1
gcloud container --project "kube-tutorial" clusters create "my-app-staging-cluster" --zone "us-east1-b" --username "admin" --cluster-version "1.11.7-gke.4" --machine-type "custom-2-8192" --image-type "COS" --disk-type "pd-standard" --disk-size "100" --scopes "https://www.googleapis.com/auth/cloud-platform" --num-nodes "3" --enable-cloud-logging --enable-cloud-monitoring --no-enable-ip-alias --network "projects/kube-tutorial/global/networks/default" --subnetwork "projects/kube-tutorial/regions/us-east1/subnetworks/default" --addons HorizontalPodAutoscaling,HttpLoadBalancing --enable-autoupgrade --enable-autorepair
Helm is a package manager for Kubernetes and the packages are called "charts" . We use this to install nginx ingress controller.
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh
chmod 700 get_helm.sh
./get_helm.sh
helm init
kubectl create namespace staging
helm init --tiller-namespace staging
kubectl create serviceaccount --namespace staging tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=staging:tiller
helm init --service-account tiller --upgrade
kubectl get deployments -n staging
In this example, I'm using an app-deploy.yaml, but you can use any image you want. (see app-deploy.yaml)
kubectl create -f app-deploy.yaml
kubectl expose deployment my-app-staging --port=8087 --namespace staging
helm install --name nginx-ingress-my-app-staging stable/nginx-ingress --set rbac.create=true --tiller-namespace staging
kubectl apply -f cloud-config/$ENV/controller-nginx.yaml
kubectl get service nginx-ingress-my-app-staging-controller
kubectl create secret tls tls-secret-staging --key my-app.com.key --cert my-app.com.crt -n staging
Create an ingress-nginx.yaml file that has your paths (see yaml file)
kubectl apply -f ingress-nginx.yaml
Browse to: http://external-ip-of-ingress-controller/
gcloud container clusters get-credentials my-app-staging-cluster
kubectl set image deployment/my-app-staging my-app-staging=gcr.io/my-repo-01/my-app-staging:<TAG HERE/> --namespace staging