Skip to content

Instantly share code, notes, and snippets.

View bharatmicrosystems's full-sized avatar
😀

Gaurav Agarwal bharatmicrosystems

😀
View GitHub Profile
$ kubectl get rs
NAME DESIRED CURRENT READY AGE
nginx-86c57db685 1 0 0 5s
$ kubectl describe rs nginx-86c57db685|tail
Conditions:
Type Status Reason
---- ------ ------
ReplicaFailure True FailedCreate
Events:
Type Reason Age From Message
$ kubectl --namespace monitoring get pods -l "release=prometheus"
NAME READY STATUS RESTARTS AGE
prometheus-prometheus-node-exporter-54svk 1/1 Running 0 80s
prometheus-prometheus-node-exporter-9kpjl 1/1 Running 0 80s
prometheus-prometheus-node-exporter-w4clh 1/1 Running 0 80s
prometheus-prometheus-oper-operator-5c8564d96d-dnzds 2/2 Running 0 80s
$ helm install prometheus stable/prometheus-operator --namespace monitoring
NAME: prometheus
LAST DEPLOYED: Thu Jul 2 23:08:57 2020
NAMESPACE: monitoring
STATUS: deployed
REVISION: 1
NOTES:
The Prometheus Operator has been installed. Check its status by running:
kubectl --namespace monitoring get pods -l "release=prometheus"
Visit https://github.com/coreos/prometheus-operator for instructions on how
$ wget https://get.helm.sh/helm-v3.2.4-linux-amd64.tar.gz
$ tar -xvf helm-v3.2.4-linux-amd64.tar.gz
$ sudo mv linux-amd64/helm /usr/bin/
$ sudo chmod +x /usr/bin/helm
$ helm version
version.BuildInfo{Version:"v3.2.1", GitCommit:"fe51cd1e31e6a202cba7dead9552a6d418ded79a", GitTreeState:"clean", GoVersion:"go1.13.10"}
Questions are not from any actual exam!!!
Q: Create a job that calculates pi to 2000 decimal points using the container with the image named perl
and the following commands issued to the container: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
Once the job has completed, check the logs to and export the result to pi-result.txt.
Solution:
$ gcloud functions deploy stopInstancePubSub \
--trigger-topic stop-instance-event \
--runtime nodejs10 \
--region europe-west2 \
--ingress-settings internal-only \
--service-account compute-instance-admin-sa@<project-id>.iam.gserviceaccount.com
Allow unauthenticated invocations of new function
[stopInstancePubSub]? (y/N)? N
WARNING: Function created with limited-access IAM policy. To enable unauthorized access consider "gcloud alpha functions add-iam-policy-binding stopInstancePubSub --member=allUsers --role=roles/cloudfunctions.invoker"
Deploying function (may take a while - up to 2 minutes)...⠹
$ gcloud functions deploy startInstancePubSub \
--trigger-topic start-instance-event \
--runtime nodejs10 \
--region europe-west2 \
--ingress-settings internal-only \
--service-account compute-instance-admin-sa@<project-id>.iam.gserviceaccount.com
Allow unauthenticated invocations of new function
[startInstancePubSub]? (y/N)? N
WARNING: Function created with limited-access IAM policy. To enable unauthorized access consider "gcloud alpha functions add-iam-policy-binding startInstancePubSub --member=allUsers --role=roles/cloudfunctions.invoker"
Deploying function (may take a while - up to 2 minutes)...⠹
$ gcloud compute instances create instance-1 \
--image-family ubuntu-1804-lts \
--image-project ubuntu-os-cloud \
--zone europe-west2-c \
--labels env=dev
Created [https://www.googleapis.com/compute/v1/projects/<project_id>/zones/europe-west2-c/instances/instance-1].
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
instance-1 europe-west2-c n1-standard-1 10.154.0.2 34.89.100.12 RUNNING
$ tree
.
|-- environments
| |-- dev
| | |-- main.tf
| | |-- outputs.tf
| | |-- terraform.tfvars
| | |-- variables.tf
| | `-- versions.tf
| |-- prod
output "bucketname" {
value = aws_s3_bucket.tf_code.id
}