diff --git a/.gitignore b/.gitignore index 1b883c8..ca03682 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ gcpServiceAccount/credentials.json -storage/.terraform/plugins +storage/.terraform +storage/.terraform* +storage/terraform* diff --git a/README.md b/README.md index cbec3d9..34cde38 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,57 @@ docker run -it --rm -v ${PWD}/storage:/storage -w /storage akshit8/terraform chmod +x .terraform/providers/registry.terraform.io/hashicorp/google/3.54.0/linux_amd64/terraform-provider-google_v3.54.0_x5 ``` + +## setting up a test cluster with kind +```bash +kind create cluster --name test-cluster --image kindest/node:v1.17.0 + +docker run -it --rm -v ${HOME}:/root/ -v ${PWD}:/work -w /work --net host debian:buster + +apt-get update && apt install curl vim + +curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl + +chmod +x ./kubectl + +mv ./kubectl /usr/local/bin/kubectl + +root@my-vm:/work# kubectl get nodes +NAME STATUS ROLES AGE VERSION +test-cluster-control-plane Ready master 5m15s v1.17.0 + +curl -L -o /tmp/velero.tar.gz https://github.com/vmware-tanzu/velero/releases/download/v1.5.1/velero-v1.5.1-linux-amd64.tar.gz + +tar -C /tmp -xvf /tmp/velero.tar.gz + +mv /tmp/velero-v1.5.1-linux-amd64/velero /usr/local/bin/velero + +chmod +x /usr/local/bin/velero + +velero --help + +kubectl create ns sample + +kubectl -n sample apply -f ./k8s-objects + +export BUCKET=velero-akshit +export REGION=asia-east1 + +velero install \ + --provider gcp \ + --plugins velero/velero-plugin-for-gcp:v1.1.0 \ + --bucket $BUCKET \ + --secret-file ./gcpServiceAccount/credentials.json + +root@my-vm:/work# kubectl -n velero get pods +NAME READY STATUS RESTARTS AGE +velero-86bb45cdfb-987ps 1/1 Running 0 23s + +kubectl logs deployment/velero -n velero + +velero backup create sample-namespace-backup --include-namespaces sample + +velero backup describe sample-namespace-backup + +velero backup logs sample-namespace-backup +``` diff --git a/k8s-objects/deployment.yml b/k8s-objects/deployment.yml index f468238..312bc73 100644 --- a/k8s-objects/deployment.yml +++ b/k8s-objects/deployment.yml @@ -38,18 +38,4 @@ spec: cpu: "50m" limits: memory: "256Mi" - cpu: "500m" -#NOTE: comment out `volumeMounts` section for configmap and\or secret guide - volumeMounts: - - name: secret-volume - mountPath: /secrets/ - - name: config-volume - mountPath: /configs/ -#NOTE: comment out `volumes` section for configmap and\or secret guide - volumes: - - name: secret-volume - secret: - secretName: sample-secret - - name: config-volume - configMap: - name: sample-config #name of our configmap object \ No newline at end of file + cpu: "500m" \ No newline at end of file diff --git a/storage/main.tf b/storage/main.tf index 88773fe..dbcdae5 100644 --- a/storage/main.tf +++ b/storage/main.tf @@ -20,8 +20,4 @@ resource "google_storage_bucket" "k8s-backup" { location = "ASIA-EAST1" storage_class = "STANDARD" - - labels { - usage = "storage bucket for k8s backup and restoration" - } } \ No newline at end of file diff --git a/storage/variables.tf b/storage/variables.tf index 277d4d8..aa7abab 100644 --- a/storage/variables.tf +++ b/storage/variables.tf @@ -9,6 +9,6 @@ variable "region" { } variable "credentials_file" { - default = "gcpServiceAccount/credentials.json" + default = "../gcpServiceAccount/credentials.json" description = "credential file name" } \ No newline at end of file