student_04_61f5f7cf52ff@cloudshell:~ (qwiklabs-gcp-00-a051edc2be39)$ gcloud auth list
student_04_61f5f7cf52ff@cloudshell:~ (qwiklabs-gcp-00-a051edc2be39)$ gcloud container clusters get-credentials gmp-cluster --zone us-east1-b
ketan_patel@cloudshell:~ (new-user-learning)$ gcloud beta container clusters create gmp-cluster --num-nodes=1 --enable-managed-prometheus
Default change: VPC-native is the default mode during cluster creation for versions greater than 1.21.0-gke.1500. To create advanced routes based clusters, please pass the `--no-enable-ip-alias` flag
Default change: During creation of nodepools or autoscaling configuration changes for cluster versions greater than 1.24.1-gke.800 a default location policy is applied. For Spot and PVM it defaults to ANY, and for all other VM kinds a BALANCED policy is used. To change the default values use the `--location-policy` flag.
Note: Your Pod address range (`--cluster-ipv4-cidr`) can accommodate at most 1008 node(s).
Creating cluster gmp-cluster in us-west1-b... Cluster is being health-checked (master is healthy)...done.
Created [https://container.googleapis.com/v1beta1/projects/new-user-learning/zones/us-west1-b/clusters/gmp-cluster].
To inspect the contents of your cluster, go to: https://console.cloud.google.com/kubernetes/workload_/gcloud/us-west1-b/gmp-cluster?project=new-user-learning
kubeconfig entry generated for gmp-cluster.
NAME: gmp-cluster
LOCATION: us-west1-b
MASTER_VERSION: 1.27.3-gke.100
MASTER_IP: X.X.X.X
MACHINE_TYPE: e2-medium
NODE_VERSION: 1.27.3-gke.100
NUM_NODES: 1
STATUS: RUNNING
ketan_patel@cloudshell:~ (new-user-learning)$ gcloud container clusters get-credentials gmp-cluster
Fetching cluster endpoint and auth data.
kubeconfig entry generated for gmp-cluster.
ketan_patel@cloudshell:~ (new-user-learning)$ kubectl config current-context
gke_new-user-learning_us-west1-b_gmp-cluster
ketan_patel@cloudshell:~ (new-user-learning)$ kubectl get deployment
No resources found in default namespace.
ketan_patel@cloudshell:~ (new-user-learning)$ kubectl get deployment -A
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
gmp-system gmp-operator 1/1 1 1 29m
gmp-system rule-evaluator 1/1 1 1 29m
kube-system event-exporter-gke 1/1 1 1 30m
kube-system konnectivity-agent 1/1 1 1 29m
kube-system konnectivity-agent-autoscaler 1/1 1 1 29m
kube-system kube-dns 1/1 1 1 30m
kube-system kube-dns-autoscaler 1/1 1 1 30m
kube-system l7-default-backend 1/1 1 1 29m
kube-system metrics-server-v0.5.2 1/1 1 1 29m
ketan_patel@cloudshell:~ (new-user-learning)$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
gke-gmp-cluster-default-pool-4defca36-jkbh Ready <none> 29m v1.27.3-gke.100
ketan_patel@cloudshell:~ (new-user-learning)$ kubectl get services -A
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 30m
gmp-system alertmanager ClusterIP None <none> 9093/TCP 29m
gmp-system gmp-operator ClusterIP 10.0.9.243 <none> 8443/TCP,443/TCP 29m
kube-system default-http-backend NodePort 10.0.6.173 <none> 80:31366/TCP 30m
kube-system kube-dns ClusterIP 10.0.0.10 <none> 53/UDP,53/TCP 30m
kube-system metrics-server ClusterIP 10.0.10.0 <none> 443/TCP 29m
ketan_patel@cloudshell:~ (new-user-learning)$ kubectl get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
gmp-system alertmanager-0 2/2 Running 0 29m
gmp-system collector-gr6zl 2/2 Running 0 28m
gmp-system gmp-operator-6888d59866-8982x 1/1 Running 0 30m
gmp-system rule-evaluator-77976dd4d9-qsqmx 2/2 Running 2 (28m ago) 28m
kube-system event-exporter-gke-7bf6c99dcb-cksqf 2/2 Running 0 30m
kube-system fluentbit-gke-bmcr6 2/2 Running 0 29m
kube-system gke-metrics-agent-2cwx7 2/2 Running 0 29m
kube-system konnectivity-agent-758789cc74-xwk4w 1/1 Running 0 30m
kube-system konnectivity-agent-autoscaler-5d9dbcc6d8-9qltt 1/1 Running 0 30m
kube-system kube-dns-5bfd847c64-jjr4j 4/4 Running 0 30m
kube-system kube-dns-autoscaler-84b8db4dc7-wp45d 1/1 Running 0 30m
kube-system kube-proxy-gke-gmp-cluster-default-pool-4defca36-jkbh 1/1 Running 0 28m
kube-system l7-default-backend-d86c96845-rgqwf 1/1 Running 0 30m
kube-system metrics-server-v0.5.2-6bf74b5d5f-wpp9p 2/2 Running 0 28m
kube-system pdcsi-node-h95cv 2/2 Running 0 29m
ketan_patel@cloudshell:~ (new-user-learning)$ kubectl create ns gmp-test
namespace/gmp-test created
ketan_patel@cloudshell:~ (new-user-learning)$ kubectl get ns
NAME STATUS AGE
default Active 31m
gmp-public Active 30m
gmp-system Active 30m
gmp-test Active 24s
kube-node-lease Active 31m
kube-public Active 31m
kube-system Active 31m
ketan_patel@cloudshell:~ (new-user-learning)$ kubectl -n gmp-test apply -f https://raw.githubusercontent.com/kyleabenson/flask_telemetry/master/gmp_prom_setup/flask_deployment.yaml
deployment.apps/helloworld-gke created
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$ kubectl -n gmp-test apply -f https://raw.githubusercontent.com/kyleabenson/flask_telemetry/master/gmp_prom_setup/flask_service.yaml
service/hello created
ketan_patel@cloudshell:~ (new-user-learning)$ kubectl get pods -n gmp-test
NAME READY STATUS RESTARTS AGE
helloworld-gke-5f574446d7-97gx7 1/1 Running 0 21s
ketan_patel@cloudshell:~ (new-user-learning)$ kubectl get services -n gmp-test
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello LoadBalancer 10.0.7.206 <pending> 80:30322/TCP 18s
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$ kubectl get services -n gmp-test
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello LoadBalancer 10.0.7.206 <pending> 80:30322/TCP 31s
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$ url=$(kubectl get services -n gmp-test -o jsonpath='{.items[*].status.loadBalancer.ingress[0].ip}')
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$ echo $url
ketan_patel@cloudshell:~ (new-user-learning)$ echo $url
ketan_patel@cloudshell:~ (new-user-learning)$ url=$(kubectl get services -n gmp-test -o jsonpath='{.items[*].status.loadBalancer.ingress[0].ip}')
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$ echo $url
35.199.168.92
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$ curl $url/metrics
# HELP flask_exporter_info Multiprocess metric
# TYPE flask_exporter_info gauge
flask_exporter_info{version="0.18.5"} 1.0
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$ kubectl -n gmp-test apply -f https://raw.githubusercontent.com/kyleabenson/flask_telemetry/master/gmp_prom_setup/prom_deploy.yaml
podmonitoring.monitoring.googleapis.com/prom-example created
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$ timeout 120 bash -c -- 'while true; do curl $(kubectl get services -n gmp-test -o jsonpath='{.items[*].status.loadBalancer.ingress[0].ip}'); sleep $((RANDOM % 4)) ; done'
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:20 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:23 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:24 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:26 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:27 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:29 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:31 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:34 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:35 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:38 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:41 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:42 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:43 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:46 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:48 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:50 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:50 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:54 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:54 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:56 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:57 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:59 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:28:59 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:02 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:05 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:05 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:08 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:09 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:12 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:15 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:18 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:21 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:22 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:25 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:28 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:29 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:31 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:31 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:33 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:33 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:36 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:36 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:38 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:40 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:41 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:43 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:46 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:47 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:49 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:52 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:54 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:55 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:57 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:57 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:29:58 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:30:01 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:30:01 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:30:02 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:30:03 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:30:04 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:30:06 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:30:07 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:30:10 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:30:10 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:30:12 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:30:15 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:30:15 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:30:16 GMT"}
{"message":"Hello World!","severity":"info","timestamp":"Thu, 26 Oct 2023 19:30:19 GMT"}
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$
ketan_patel@cloudshell:~ (new-user-learning)$ gcloud monitoring dashboards create --config='''
{
"category": "CUSTOM",
"displayName": "Prometheus Dashboard Example",
"mosaicLayout": {
"columns": 12,
"tiles": [
{
"height": 4,
"widget": {
"title": "prometheus/flask_http_request_total/counter [MEAN]",
"xyChart": {
"chartOptions": {
"mode": "COLOR"
},
"dataSets": [
{
"minAlignmentPeriod": "60s",
"plotType": "LINE",
"targetAxis": "Y1",
"timeSeriesQuery": {
"apiSource": "DEFAULT_CLOUD",
"timeSeriesFilter": {
"aggregation": {
"alignmentPeriod": "60s",
"crossSeriesReducer": "REDUCE_NONE",
"perSeriesAligner": "ALIGN_RATE"
},
"filter": "metric.type=\"prometheus.googleapis.com/flask_http_request_total/counter\" resource.type=\"pro''' ] } "yPos": 0,,e": "LINEAR", "0s",r": "ALIGN_MEAN"AN",
Created [7ac033b1-4bd1-4116-b236-397d55fb783c].
ketan_patel@cloudshell:~ (new-user-learning)$