Skip to content

sandesvitor/simple-gke-build

Repository files navigation

Start Google Cloud Docker Container, Auth and Create Cluster:

$ sudo docker run -it --rm -v ${PWD}:/work -w /work --entrypoint /bin/bash google/cloud-sdk:160.0.0
$ cd /work
$ gcloud auth login

Copy the link given by the command in your browser.

Then, after authentication, copy the link provided by google in the shell.


After that, set your project ID where you will make your changes (if you doesn't have any project or want to create a new one, type gcloud projects create <NAME_OF_THE_PROJECT>)

$ gcloud config set project <PROJECT_ID>

Check K8s versions for region

$ gcloud container get-server-config --zone southamerica-east1-a

$ gcloud container clusters create <NAME_OF_THE_PROJECT> \
--cluster-version 1.18.16-gke.300 \
--disk-size 10 \
--num-nodes 1 \
--machine-type e2-small \
--no-enable-cloud-endpoints \
--no-enable-cloud-logging \
--no-enable-cloud-monitoring \
--zone southamerica-east1-a

After the cluster is up, install kubectl and get kubeconfig for your cluster:

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

Validate the binary with checksum file:

$ curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"

$ echo "$(<kubectl.sha256) kubectl" | sha256sum --check

Install kubectl:

$ install -o root -g root -m 0755 kubectl /usr/bin/kubectl

Check if client are within one minor version difference of your cluster (server).

$ kubectl version --short
Client Version: v1.6.4
Server Version: v1.18.16-gke.300

If not, remove and download the proper version (or downgrade your server). https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/


Fetching the kubeconfig to our cluster:

gcloud container clusters get-credentials <NAME_OF_THE_PROJECT> --zone southamerica-east1-a

Generate Configmap to custom /usr/share/nginx/html/index.html

$ kubectl create configmap nginx-index-html-configmap --from-file=index.html -o yaml --dry-run=client

Clean up! (or get poor)

$ gcloud container clusters delete <NAME_OF_THE_PROJECT> --zone southamerica-east1-a

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published