<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Jasper Rodda</title>
    <description>The latest articles on Forem by Jasper Rodda (@jasper475).</description>
    <link>https://forem.com/jasper475</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1144162%2F2aff6412-8659-473a-8f3e-45a66b5cee3d.jpeg</url>
      <title>Forem: Jasper Rodda</title>
      <link>https://forem.com/jasper475</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/jasper475"/>
    <language>en</language>
    <item>
      <title>Python Interview Question - Beginner to Advance</title>
      <dc:creator>Jasper Rodda</dc:creator>
      <pubDate>Wed, 28 Aug 2024 21:19:58 +0000</pubDate>
      <link>https://forem.com/jasper475/python-interview-question-beginner-to-advance-1omp</link>
      <guid>https://forem.com/jasper475/python-interview-question-beginner-to-advance-1omp</guid>
      <description>&lt;h4&gt;
  
  
  1. Interviewer: Write a Python code to get output as mentioned below.
&lt;/h4&gt;

&lt;h4&gt;
  
  
  Time: 15 Min
&lt;/h4&gt;

&lt;h4&gt;
  
  
  Level: Beginner
&lt;/h4&gt;

&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input = "AAAABBBCCDAABBB"
Output= A4B3C2D1A2B3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Possible Answer
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# define a function() that takes string input and return null if string is null and returns 1st occurrences of character followed by number of occurrences and so on. 

# This function takes a string and returns processed string output. 
def str_skimmer(input_string):
    # Return null string if input is null. 
    if not input_string:
        return ""
    # Store values for 2 parameters - "Reference Character and "Count"
    prev_char=input_string[0]
    op=[]
    count=1

    for i in input_string[1:]:
        if (i==prev_char):
            count += 1 
            print(i, count, op)
        else: 
            op.append(prev_char+str(count))
            prev_char=i
            count=1
    op.append(prev_char+str(count))  
    print(op)

    return ''.join(op)
#O: A4B3C2D1A2B3

ip="AAAABBBCCDAABBB"
op= str_skimmer(ip)
print(op)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. Interviewer: TBD
&lt;/h4&gt;

&lt;h4&gt;
  
  
  Time: 15 Min
&lt;/h4&gt;

&lt;h4&gt;
  
  
  Level: Beginner
&lt;/h4&gt;

&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input = "TBD"
Output= TBD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>interview</category>
      <category>career</category>
    </item>
    <item>
      <title>Install Hashicorp Vault to store Secrets and use it in Terraform.</title>
      <dc:creator>Jasper Rodda</dc:creator>
      <pubDate>Sun, 11 Feb 2024 03:06:35 +0000</pubDate>
      <link>https://forem.com/jasper475/installation-hashicorp-vault-10o9</link>
      <guid>https://forem.com/jasper475/installation-hashicorp-vault-10o9</guid>
      <description>&lt;h2&gt;
  
  
  1. Installation Steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Install gpg
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update &amp;amp;&amp;amp; sudo apt install gpg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Download the signing key to a new keyring
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Verify the key's fingerprint
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprint
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add the HashiCorp repo
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Update packages
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install Vault
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install vault
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Start Vault Server
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Start Vault Server
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vault server -dev -dev-listen-address="0.0.0.0:8200"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Configure Terraform to read the secret from Vault.
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Enable AppRole Authentication:
&amp;gt; To enable the AppRole authentication method in Vault, you need to use the Vault CLI or the Vault HTTP API.&lt;/li&gt;
&lt;li&gt;Run the following command to enable the AppRole authentication method:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vault auth enable approle
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create an AppRole:&lt;/li&gt;
&lt;li&gt;2.a) Create Policy
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vault policy write terraform - &amp;lt;&amp;lt;EOF
path "*" {
  capabilities = ["list", "read"]
}

path "secrets/data/*" {
  capabilities = ["create", "read", "update", "delete", "list"]
}

path "kv/data/*" {
  capabilities = ["create", "read", "update", "delete", "list"]
}


path "secret/data/*" {
  capabilities = ["create", "read", "update", "delete", "list"]
}

path "auth/token/create" {
capabilities = ["create", "read", "update", "list"]
}
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.b) Create the AppRole:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vault write auth/approle/role/terraform \
    secret_id_ttl=10m \
    token_num_uses=10 \
    token_ttl=20m \
    token_max_ttl=30m \
    secret_id_num_uses=40 \
    token_policies=terraform
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Generate Role ID and Secret ID:
&amp;gt; After creating the AppRole, you need to generate a Role ID and Secret ID pair. The Role ID is a static identifier, while the Secret ID is a dynamic credential.&lt;/li&gt;
&lt;li&gt;3.a) Generate Role ID:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vault read auth/approle/role/my-approle/role-id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;3.b) Generate Secret ID:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vault write -f auth/approle/role/my-approle/secret-id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command generates a Secret ID and provides it in the response. Save the Secret ID securely, as it will be used for Terraform authentication.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Provider.tf file
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;provider "vault" {
  address = "&amp;lt;&amp;gt;:8200"
  skip_child_token = true

  auth_login {
    path = "auth/approle/login"

    parameters = {
      role_id = "&amp;lt;&amp;gt;"
      secret_id = "&amp;lt;&amp;gt;"
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Main.tf
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;5.a) Create vault server
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Create vault server - 1 
resource "aws_instance" "vault-server-1" {
  ami                    = "ami-053b0d53c279acc90"
  instance_type          = "t2.micro"
  key_name               = "efronlogin"
  subnet_id              = aws_subnet.sd-snet1.id
  vpc_security_group_ids = [aws_security_group.sd-sg-1.id]
  user_data              = base64encode(file("vault_userdata.sh"))

   tags = {
    name="vault-Master"
    Environment="dev"
  }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;5.b) Connect to Hashicorp Vault via "data" resource
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; data "vault_kv_secret_v2" "example" {
   mount = "secret" // change it according to your mount
   name  = "dev-s3" // change it according to your secret
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;5.c) Use it to retrieve in Terraform&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;create EC2 instance with Tag names and Secret Name&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resource "aws_instance" "my_instance" {
  ami           = "ami-053b0d53c279acc90"
  instance_type = "t2.micro"

  tags = {
    Name = "test"
    Secret = data.vault_kv_secret_v2.example.data["secret_name"]
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Credits:-&lt;/strong&gt;&lt;br&gt;
Thanks to &lt;a href="https://www.youtube.com/@AbhishekVeeramalla"&gt;Abhishek Veeramalla&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>devops</category>
      <category>hashicorpvault</category>
    </item>
    <item>
      <title>Deploy pods on Kubernetes Cluster in localhost</title>
      <dc:creator>Jasper Rodda</dc:creator>
      <pubDate>Tue, 23 Jan 2024 17:34:40 +0000</pubDate>
      <link>https://forem.com/jasper475/deploy-pods-on-kubernetes-cluster-in-localhost-4ln6</link>
      <guid>https://forem.com/jasper475/deploy-pods-on-kubernetes-cluster-in-localhost-4ln6</guid>
      <description>&lt;h4&gt;
  
  
  Pre-requisites:
&lt;/h4&gt;

&lt;p&gt;Below are essentials before you start deploying containers into kubernetes cluster&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install &lt;a href="https://docs.docker.com/engine/install/"&gt;docker &lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Install &lt;a href="https://www.virtualbox.org/wiki/Downloads"&gt;Virtual Box (Type II Hypervisor)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Install &lt;a href="https://minikube.sigs.k8s.io/docs/start/"&gt;Minikube (Kubernetes on local)&lt;/a&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Verify Docker &amp;amp; Minikube installed correctly:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;To verify docker type "docker" in powershell and see if you get below options. &lt;code&gt;PS C:\WINDOWS\system32&amp;gt; docker&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; docker
Usage:  docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
      --config string      Location of client config files (default
                           "C:\\Users\\Jasper\\.docker")
  -c, --context string     Name of the context to use to connect to the
                           daemon (overrides DOCKER_HOST env var and
                           default context set with "docker context use")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To verify Minikube, type "minikube" in powershell and see if you get below options. &lt;code&gt;PS C:\WINDOWS\system32&amp;gt; minikube&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; minikube
minikube provisions and manages local Kubernetes clusters optimized for development workflows.
Basic Commands:
  start            Starts a local Kubernetes cluster
  status           Gets the status of a local Kubernetes cluster
  stop             Stops a running local Kubernetes cluster
  delete           Deletes a local Kubernetes cluster
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 1: Create Kubernetes cluster
&lt;/h2&gt;

&lt;p&gt;1.create Mikikube &lt;a href="https://minikube.sigs.k8s.io/docs/drivers/virtualbox/"&gt;cluster&lt;/a&gt; on VirtualBox VM&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;minikube start --driver=virtualbox
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Get cluster information&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; kubectl cluster-info
Kubernetes control plane is running at https://192.168.XX.XXX:8443
CoreDNS is running at https://192.168.XX.XXX:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.get nodes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; kubectl get nodes
NAME       STATUS   ROLES           AGE   VERSION
minikube   Ready    control-plane   13m   v1.27.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.get namespaces&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; kubectl get namespaces
NAME              STATUS   AGE
default           Active   14m
kube-node-lease   Active   14m
kube-public       Active   14m
kube-system       Active   14m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.get All pods&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; kubectl get pods -A
NAMESPACE     NAME                               READY   STATUS    RESTARTS      AGE
kube-system   coredns-5d78c9869d-df2qj           1/1     Running   0             14m
kube-system   etcd-minikube                      1/1     Running   0             14m
kube-system   kube-apiserver-minikube            1/1     Running   0             14m
kube-system   kube-controller-manager-minikube   1/1     Running   0             14m
kube-system   kube-proxy-8zw65                   1/1     Running   0             14m
kube-system   kube-scheduler-minikube            1/1     Running   0             14m
kube-system   storage-provisioner                1/1     Running   1 (13m ago)   14m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>kubernetes</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>minikube</category>
    </item>
    <item>
      <title>Install Prometheus and Grafana on Kubernetes Cluster.</title>
      <dc:creator>Jasper Rodda</dc:creator>
      <pubDate>Mon, 22 Jan 2024 20:47:08 +0000</pubDate>
      <link>https://forem.com/jasper475/install-prometheus-and-grafana-on-kubernetes-cluster-21d8</link>
      <guid>https://forem.com/jasper475/install-prometheus-and-grafana-on-kubernetes-cluster-21d8</guid>
      <description>&lt;p&gt;&lt;em&gt;Prometheus is an open-source monitoring and alerting system that helps you collect and store metrics about your software systems and infrastructure and analyze that data to gain insights into their health and performance. It provides a powerful query language, a flexible data model, and a range of integrations with other tools and systems. With Prometheus, you can easily monitor metrics such as CPU usage, memory usage, network traffic, and application-specific metrics, and use that data to troubleshoot issues, optimize performance, and create alerts to notify you when things go wrong.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Install Prometheus via 2 ways.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Helm Charts&lt;/li&gt;
&lt;li&gt;Operators&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Using operators, using Operator life cycle management (OLM) one can automatically have latest updates without worrying to update manually and therefore securing cluster with zero-day vulnerabilities.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Install using Helm.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Add helm repo
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Update helm repo
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm repo update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Install helm
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm install prometheus prometheus-community/prometheus
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; helm install prometheus prometheus-community/prometheus
NAME: prometheus
LAST DEPLOYED: Mon Jan 22 12:55:19 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
The Prometheus server can be accessed via port 80 on the following DNS name from within your cluster:
prometheus-server.default.svc.cluster.local


Get the Prometheus server URL by running these commands in the same shell:
  export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=prometheus,app.kubernetes.io/instance=prometheus" -o jsonpath="{.items[0].metadata.name}")
  kubectl --namespace default port-forward $POD_NAME 9090


The Prometheus alertmanager can be accessed via port 9093 on the following DNS name from within your cluster:
prometheus-alertmanager.default.svc.cluster.local


Get the Alertmanager URL by running these commands in the same shell:
  export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=alertmanager,app.kubernetes.io/instance=prometheus" -o jsonpath="{.items[0].metadata.name}")
  kubectl --namespace default port-forward $POD_NAME 9093
#################################################################################
######   WARNING: Pod Security Policy has been disabled by default since    #####
######            it deprecated after k8s 1.25+. use                        #####
######            (index .Values "prometheus-node-exporter" "rbac"          #####
###### .          "pspEnabled") with (index .Values                         #####
######            "prometheus-node-exporter" "rbac" "pspAnnotations")       #####
######            in case you still need it.                                #####
#################################################################################


The Prometheus PushGateway can be accessed via port 9091 on the following DNS name from within your cluster:
prometheus-prometheus-pushgateway.default.svc.cluster.local


Get the PushGateway URL by running these commands in the same shell:
  export POD_NAME=$(kubectl get pods --namespace default -l "app=prometheus-pushgateway,component=pushgateway" -o jsonpath="{.items[0].metadata.name}")
  kubectl --namespace default port-forward $POD_NAME 9091

For more information on running Prometheus, visit:
https://prometheus.io/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  - Verify Prometheus Pods Running
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl get pods
NAME                                                 READY   STATUS    RESTARTS        AGE
prometheus-alertmanager-0                            1/1     Running   0               3m8s
prometheus-kube-state-metrics-745b475957-ngqm7       1/1     Running   0               3m8s
prometheus-prometheus-node-exporter-698nc            1/1     Running   0               3m8s
prometheus-prometheus-pushgateway-6ccd698d79-ld86d   1/1     Running   0               3m8s
prometheus-server-bc7ccb595-jpl7p                    2/2     Running   0               3m8s
sample-python-deployment-99fcf4b6f-rb59w             1/1     Running   2 (5m40s ago)   8d
sample-python-deployment-99fcf4b6f-vcnwt             1/1     Running   2 (5m40s ago)   8d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  - Verify Prometheus services via &lt;code&gt;Kubectl get svc&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl get svc
NAME                                  TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
kubernetes                            ClusterIP      10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        8d
prometheus-alertmanager               ClusterIP      10.100.6.213     &amp;lt;none&amp;gt;        9093/TCP       7m38s
prometheus-alertmanager-headless      ClusterIP      None             &amp;lt;none&amp;gt;        9093/TCP       7m38s
prometheus-kube-state-metrics         ClusterIP      10.103.166.42    &amp;lt;none&amp;gt;        8080/TCP       7m38s
prometheus-prometheus-node-exporter   ClusterIP      10.104.211.162   &amp;lt;none&amp;gt;        9100/TCP       7m38s
prometheus-prometheus-pushgateway     ClusterIP      10.100.179.109   &amp;lt;none&amp;gt;        9091/TCP       7m38s
prometheus-server                     ClusterIP      10.105.170.132   &amp;lt;none&amp;gt;        80/TCP         7m38s
sample-python-service                 LoadBalancer   10.101.160.8     &amp;lt;pending&amp;gt;     80:30007/TCP   8d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Expose Prometheus Service
&lt;/h3&gt;

&lt;p&gt;This is required to access prometheus-server using your browser.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl expose service prometheus-server --type=NodePort --target-port=9090 --name=prometheus-server-ext
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Notice below is created &lt;code&gt;prometheus-server-ext                 NodePort       10.99.142.160    &amp;lt;none&amp;gt;        80:31401/TCP   3s&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get svc&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; kubectl get svc
NAME                                  TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
kubernetes                            ClusterIP      10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        8d
prometheus-alertmanager               ClusterIP      10.100.6.213     &amp;lt;none&amp;gt;        9093/TCP       10m
prometheus-alertmanager-headless      ClusterIP      None             &amp;lt;none&amp;gt;        9093/TCP       10m
prometheus-kube-state-metrics         ClusterIP      10.103.166.42    &amp;lt;none&amp;gt;        8080/TCP       10m
prometheus-prometheus-node-exporter   ClusterIP      10.104.211.162   &amp;lt;none&amp;gt;        9100/TCP       10m
prometheus-prometheus-pushgateway     ClusterIP      10.100.179.109   &amp;lt;none&amp;gt;        9091/TCP       10m
prometheus-server                     ClusterIP      10.105.170.132   &amp;lt;none&amp;gt;        80/TCP         10m
prometheus-server-ext                 NodePort       10.99.142.160    &amp;lt;none&amp;gt;        80:31401/TCP   3s
sample-python-service                 LoadBalancer   10.101.160.8     &amp;lt;pending&amp;gt;     80:30007/TCP   8d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl expose service prometheus-server --type=NodePort --target-port=9090 --name=prometheus-server-ext
service/prometheus-server-ext exposed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Get Minikube IP
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;minikube ip
192.168.59.107
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Open Browser and access Prometheus
&lt;/h3&gt;

&lt;h2&gt;
  
  
  - Go to &lt;a href="http://192.168.59.107:31401/"&gt;http://192.168.59.107:31401/&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxn9ij3wmz3mfx6uczmlp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxn9ij3wmz3mfx6uczmlp.png" alt="Prometheus Dashboard" width="800" height="208"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Grafana
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Install using Helm
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Add helm repo &lt;/li&gt;
&lt;li&gt;_Ignore is you already have help and grafana repo added _
&lt;code&gt;helm repo add grafana https://grafana.github.io/helm-charts&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$helm repo add grafana https://grafana.github.io/helm-charts
"grafana" has been added to your repositories
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Update helm repo
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;helm repo update&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "eks" chart repository
...Successfully got an update from the "istio" chart repository
...Successfully got an update from the "grafana" chart repository
...Successfully got an update from the "prometheus-community" chart repository
Update Complete. ⎈Happy Helming!⎈
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Install Grafana via helm
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;helm install grafana grafana/grafana&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ helm install grafana grafana/grafana
NAME: grafana
LAST DEPLOYED: Mon Jan 22 13:20:52 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get your 'admin' user password by running:

   kubectl get secret --namespace default grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo


2. The Grafana server can be accessed via port 80 on the following DNS name from within your cluster:

   grafana.default.svc.cluster.local

   Get the Grafana URL to visit by running these commands in the same shell:
     export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=grafana" -o jsonpath="{.items[0].metadata.name}")
     kubectl --namespace default port-forward $POD_NAME 3000

3. Login with the password from step 1 and the username: admin
#################################################################################
######   WARNING: Persistence is disabled!!! You will lose your data when   #####
######            the Grafana pod is terminated.                            #####
#################################################################################
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Get Grafana Login Details
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Get password: &lt;code&gt;$ kubectl get secret --namespace default grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl get secret --namespace default grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
XPhzARnKv93uhRGt8Nu9cimhuAHZoj64ZtCHDeQd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Get Grafana services &lt;code&gt;kubectl get svc&lt;/code&gt; Notice its running on Cluster IP
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get svc
NAME                                  TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
grafana                               ClusterIP      10.109.8.93      &amp;lt;none&amp;gt;        80/TCP         8m12s
kubernetes                            ClusterIP      10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        8d
prometheus-alertmanager               ClusterIP      10.100.6.213     &amp;lt;none&amp;gt;        9093/TCP       33m
prometheus-alertmanager-headless      ClusterIP      None             &amp;lt;none&amp;gt;        9093/TCP       33m
prometheus-kube-state-metrics         ClusterIP      10.103.166.42    &amp;lt;none&amp;gt;        8080/TCP       33m
prometheus-prometheus-node-exporter   ClusterIP      10.104.211.162   &amp;lt;none&amp;gt;        9100/TCP       33m
prometheus-prometheus-pushgateway     ClusterIP      10.100.179.109   &amp;lt;none&amp;gt;        9091/TCP       33m
prometheus-server                     ClusterIP      10.105.170.132   &amp;lt;none&amp;gt;        80/TCP         33m
prometheus-server-ext                 NodePort       10.99.142.160    &amp;lt;none&amp;gt;        80:31401/TCP   23m
sample-python-service                 LoadBalancer   10.101.160.8     &amp;lt;pending&amp;gt;     80:30007/TCP   8d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Expose Grafana Service to Access IT
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl expose service grafana --type=NodePort --target-port=3000 --name=grafana-ext
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Verify exposed Grafana service
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl expose service grafana --type=NodePort --target-port=3000 --name=grafana-ext
service/grafana-ext exposed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Get Grafana-Ext Service at port &lt;code&gt;30197&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; kubectl get svc
NAME                                  TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
grafana                               ClusterIP      10.109.8.93      &amp;lt;none&amp;gt;        80/TCP         11m
grafana-ext                           NodePort       10.111.66.82     &amp;lt;none&amp;gt;        80:30197/TCP   51s
kubernetes                            ClusterIP      10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        8d
prometheus-alertmanager               ClusterIP      10.100.6.213     &amp;lt;none&amp;gt;        9093/TCP       37m
prometheus-alertmanager-headless      ClusterIP      None             &amp;lt;none&amp;gt;        9093/TCP       37m
prometheus-kube-state-metrics         ClusterIP      10.103.166.42    &amp;lt;none&amp;gt;        8080/TCP       37m
prometheus-prometheus-node-exporter   ClusterIP      10.104.211.162   &amp;lt;none&amp;gt;        9100/TCP       37m
prometheus-prometheus-pushgateway     ClusterIP      10.100.179.109   &amp;lt;none&amp;gt;        9091/TCP       37m
prometheus-server                     ClusterIP      10.105.170.132   &amp;lt;none&amp;gt;        80/TCP         37m
prometheus-server-ext                 NodePort       10.99.142.160    &amp;lt;none&amp;gt;        80:31401/TCP   26m
sample-python-service                 LoadBalancer   10.101.160.8     &amp;lt;pending&amp;gt;     80:30007/TCP   8d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Access via minikube IP&lt;/li&gt;
&lt;li&gt;&lt;a href="http://192.168.59.107:30197/"&gt;http://192.168.59.107:30197/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  - Login via user=&lt;code&gt;admin&lt;/code&gt; and password=&lt;code&gt;XPhzARnKv93uhRGt8Nu9cimhuAHZoj64ZtCHDeQd&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcz7pg5dxw2bhj49z9jk8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcz7pg5dxw2bhj49z9jk8.png" alt="Grafana login page" width="800" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Grafana Dashboard&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd02vadj1y2i63iyeihqr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd02vadj1y2i63iyeihqr.png" alt="Grafana Dashboard" width="800" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Configure Prometheus as Datasource to Grafana&lt;/li&gt;
&lt;li&gt;Go to Data sources --&amp;gt; Add Prometheus --&amp;gt; Provide IP Address - Save and Test&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F721cil65k6d6nmta8g31.png" alt="Save and Test configuration" width="800" height="112"&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4tkfyjloxrj942iv4m90.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4tkfyjloxrj942iv4m90.png" alt="Configure Prometheus as Datasource to Grafana" width="800" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Import an existing dashboard&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Dashboard --&amp;gt; Import --&amp;gt; Enter ID &lt;code&gt;3662&lt;/code&gt; --&amp;gt; Load&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F838tjkqqgjhvremnqwhq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F838tjkqqgjhvremnqwhq.png" alt="Import Dashboard 3662" width="800" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx2cwb1w8c23z0zh7h67o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx2cwb1w8c23z0zh7h67o.png" alt="configure Dashboard 3662" width="800" height="357"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dashboard&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiqjzp78vqdddc1knljav.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiqjzp78vqdddc1knljav.png" alt="Grafana Dashboard description" width="800" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Expose &lt;code&gt;prometheus-kube-state-metrics&lt;/code&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;How do we do it by following the steps below.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl expose service prometheus-kube-state-metrics --type=NodePort --target-port=8080 --name=prometheus-kube-state-metrics-ext
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Verify kube-state-metrics exposed
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get svc
NAME                                  TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
grafana                               ClusterIP      10.109.8.93      &amp;lt;none&amp;gt;        80/TCP           54m
grafana-ext                           NodePort       10.111.66.82     &amp;lt;none&amp;gt;        80:30197/TCP     43m
kubernetes                            ClusterIP      10.96.0.1        &amp;lt;none&amp;gt;        443/TCP          8d
prometheus-alertmanager               ClusterIP      10.100.6.213     &amp;lt;none&amp;gt;        9093/TCP         79m
prometheus-alertmanager-headless      ClusterIP      None             &amp;lt;none&amp;gt;        9093/TCP         79m
prometheus-kube-state-metrics         ClusterIP      10.103.166.42    &amp;lt;none&amp;gt;        8080/TCP         79m
prometheus-kube-state-metrics-ext     NodePort       10.100.12.19     &amp;lt;none&amp;gt;        8080:30229/TCP   15s
prometheus-prometheus-node-exporter   ClusterIP      10.104.211.162   &amp;lt;none&amp;gt;        9100/TCP         79m
prometheus-prometheus-pushgateway     ClusterIP      10.100.179.109   &amp;lt;none&amp;gt;        9091/TCP         79m
prometheus-server                     ClusterIP      10.105.170.132   &amp;lt;none&amp;gt;        80/TCP           79m
prometheus-server-ext                 NodePort       10.99.142.160    &amp;lt;none&amp;gt;        80:31401/TCP     69m
sample-python-service                 LoadBalancer   10.101.160.8     &amp;lt;pending&amp;gt;     80:30007/TCP     8d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Open browser and access via port 30229&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  - &lt;a href="http://192.168.59.107:30229/"&gt;http://192.168.59.107:30229/&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzg39d93z4s4aikccmz2a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzg39d93z4s4aikccmz2a.png" alt="Kube state metrics external service" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Kubectl get cm or configmap
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get cm
NAME                      DATA   AGE
grafana                   1      61m
kube-root-ca.crt          1      8d
prometheus-alertmanager   1      86m
prometheus-server         6      86m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Edit config map of &lt;code&gt;prometheus-server&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;kubectl edit cm prometheus-server&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;change scrpe confi from local-host to &lt;code&gt;prometheus-kube-state-metrics-ext&lt;/code&gt; service&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;BEFORE:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;scrape_configs:
    - job_name: prometheus
      static_configs:
      - targets:
        - localhost:9090
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;AFTER: Add config to &lt;code&gt;http://192.168.59.107:30229/&lt;/code&gt; state-metrics-ext
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;scrape_configs:
    - job_name: prometheus
      static_configs:
      - targets:
        - localhost:9090
    - job_name: prometheus
      static_configs:
      - targets:
        - http://192.168.59.107:30229
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Credits:-&lt;/strong&gt;&lt;br&gt;
Thanks to &lt;a href="https://www.youtube.com/@AbhishekVeeramalla"&gt;Abhishek Veeramalla&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Deploy ConfigMaps and Secrets in Red Hat OpenShift Kubernetes Cluster</title>
      <dc:creator>Jasper Rodda</dc:creator>
      <pubDate>Wed, 17 Jan 2024 20:11:15 +0000</pubDate>
      <link>https://forem.com/jasper475/deploy-configmaps-and-secrets-in-red-hat-openshift-kubernetes-cluster-16ef</link>
      <guid>https://forem.com/jasper475/deploy-configmaps-and-secrets-in-red-hat-openshift-kubernetes-cluster-16ef</guid>
      <description>&lt;p&gt;&lt;em&gt;Applications are often written to connect to a database to read and write information.  Hardcoding database connection details, port, username and password is the most insecure way and hard to manage at scale. So, Kubernetes solves this problem via &lt;code&gt;ConfigMaps&lt;/code&gt; and &lt;code&gt;Secrets&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Two ways to store data
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;ConfigMap&lt;/strong&gt;: Used to store insensitive data such as &lt;code&gt;db-port&lt;/code&gt; via an &lt;code&gt;Environment variable&lt;/code&gt; or a &lt;code&gt;File&lt;/code&gt; or &lt;code&gt;Volume Mounts&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Secret&lt;/strong&gt;: Used to store and encrypt sensitive data at rest such as &lt;code&gt;database username&lt;/code&gt; or &lt;code&gt;database password&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;etcd&lt;/strong&gt; is a &lt;code&gt;data store&lt;/code&gt; in Kubernetes which is used to store all created resources as objects. Resources such a &lt;code&gt;Pod&lt;/code&gt;, &lt;code&gt;Deployment&lt;/code&gt;, &lt;code&gt;Service&lt;/code&gt;, &lt;code&gt;Ingress&lt;/code&gt;, &lt;code&gt;ConfigMap&lt;/code&gt; are stored in &lt;code&gt;ectcd&lt;/code&gt; as plain objects. however, with &lt;code&gt;secrets&lt;/code&gt;, &lt;code&gt;etcd&lt;/code&gt; stored the information and &lt;code&gt;encrypts&lt;/code&gt; the data at rest in &lt;code&gt;base64&lt;/code&gt; encoded.&lt;/em&gt; &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  1. Deploying &lt;strong&gt;ConfigMap&lt;/strong&gt; in Kubernetes
&lt;/h3&gt;

&lt;h4&gt;
  
  
  - 1.a) ConfigMap via &lt;code&gt;Env Variable&lt;/code&gt;
&lt;/h4&gt;

&lt;h4&gt;
  
  
  - 1.b) ConfigMap via &lt;code&gt;File - Volume Mount&lt;/code&gt;
&lt;/h4&gt;




&lt;h4&gt;
  
  
  1.a) Deploy ConfigMap via &lt;code&gt;Env Variable&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;create &lt;code&gt;configmap.yml&lt;/code&gt; file as below
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: ConfigMap
metadata: 
  name: py-app-configmap
data: 
db-port: "3306"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Login to OpenShift Kubernetes cluster
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;oc login --token=sha256~asf9879SDAF987sd987sdf --server=https://api.sandbox-m3.1530.p1.openshiftapps.com:6443
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Deploy &lt;code&gt;Configmap&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl apply -f configmap.yml
configmap/py-app-configmap created
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;verify &lt;code&gt;ConfigMap&lt;/code&gt; - &lt;code&gt;$ kubectl get cm&lt;/code&gt; | &lt;code&gt;kubectl get configmap&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl get configmap
NAME                       DATA   AGE
config-service-cabundle    1      2d15h
config-trusted-cabundle    1      2d15h
kube-root-ca.crt           1      2d15h
openshift-service-ca.crt   1      2d15h
py-app-configmap           1      37s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fucqirvq1ojtf3lvk3m69.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fucqirvq1ojtf3lvk3m69.png" alt="configmap created on OpenShift" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcx6ci1g20ba7xu2c90bu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcx6ci1g20ba7xu2c90bu.png" alt="configmap yaml on OpenShift" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Kubectl Describe ConfigMap - &lt;code&gt;$kubectl describe cm  py-app-configmap&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$kubectl describe cm  py-app-configmap
Name:         py-app-configmap
Namespace:    jasper475-dev
Labels:       &amp;lt;none&amp;gt;
Annotations:  &amp;lt;none&amp;gt;

Data
====
db-port:
----
3306

BinaryData
====

Events:  &amp;lt;none&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Deploy &lt;code&gt;Pods&lt;/code&gt; and appending &lt;code&gt;configMap&lt;/code&gt; using &lt;code&gt;deployment.yml&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: apps/v1
kind: Deployment
metadata: 
  name: sample-python-deployment
  labels: 
    app: sample-python-app
spec: 
  replicas: 5
  selector: 
    matchLabels: 
      app: sample-python-app
  template: 
    metadata: 
      labels: 
        app: sample-python-app
    spec:
      containers:
      - name: python-app
        image: jasper475/d37-k8s-services-py-django-app:v2
        env:
          - name: DB-PORT
            valueFrom: 
              configMapKeyRef:
                name: py-app-configmap
                key: db-port
        ports:
        - containerPort: 8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;deployed Pods
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl apply -f deploy.yaml
deployment.apps/sample-python-deployment created
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;get Pods and ssh into it to get env variable
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl get pods
NAME                                        READY   STATUS    RESTARTS   AGE
sample-python-deployment-5787bd6b9f-5n779   1/1     Running   0          69s
sample-python-deployment-5787bd6b9f-h6th2   1/1     Running   0          69s
sample-python-deployment-5787bd6b9f-sft22   1/1     Running   0          69s
sample-python-deployment-5787bd6b9f-w7s56   1/1     Running   0          69s
sample-python-deployment-5787bd6b9f-xncfd   1/1     Running   0          69s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;SSH into a pod &lt;/li&gt;
&lt;li&gt;Command: &lt;code&gt;kubectl exec -it sample-python-deployment-5787bd6b9f-5n779 -- /bin/bash&lt;/code&gt; and Search(grep) for Env variable &lt;code&gt;DB-PORT&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Dev inside python app can retrieve via: &lt;code&gt;OS.env("DB-PORT")&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl exec -it sample-python-deployment-c57769684-749ct -- /bin/bash
groups: cannot find name for group ID 1011150000
1011150000@sample-python-deployment-c57769684-749ct:/app$ ls
db.sqlite3  demo  devops  manage.py  requirements.txt
1011150000@sample-python-deployment-c57769684-749ct:/app$ env | grep DB
DB-PORT=3306
NSS_SDB_USE_CACHE=no
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Edit DB-PORT via configmap.yml
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: ConfigMap
metadata: 
  name: py-app-configmap
data: 
  db-port: "3307"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Apply changes &lt;code&gt;kubectl apply -f configmap.yml&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl apply -f configmap.yml
configmap/py-app-configmap configured
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Notice config map Port changed to 3307
&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmge3x7hctj0qdvqn3sh4.png" alt="config map - Port 3307" width="800" height="401"&gt;
&lt;/li&gt;
&lt;li&gt;SSH into the POD to get Environment variable value. Notice it is still having OLD Value. &lt;code&gt;DB-PORT=3306&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1011150000@sample-python-deployment-c57769684-749ct:/app$ env | grep DB
DB-PORT=3306
NSS_SDB_USE_CACHE=no
1011150000@sample-python-deployment-c57769684-749ct:/app$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;We cannot afford to restart pod in production - to Fix this issue we use Volume Mounts and persist config values and decouple it from pod application restarts and config changes. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  1.b) Deploy ConfigMap via &lt;code&gt;File - Volume Mount&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;deploy_volume_Mount.yaml&lt;/code&gt; file&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;create volume under &lt;code&gt;container&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;spec: 
      containers: 
      |
      |
      volumes: 
        - name: db-connection
          configMap: 
            name: py-app-configmap

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Mount volume: provide &lt;code&gt;volume name&lt;/code&gt; and &lt;code&gt;volume path&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    spec:
      containers:
      - name: python-app
        image: jasper475/d37-k8s-services-py-django-app:v2
        volumeMounts:
          - name: db-connection
          mountPath: /opt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;apply deployment changes
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl apply -f deploy_volume_mount.yaml
deployment.apps/sample-python-deployment configured
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Get Pods &lt;code&gt;kubectl get pods&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl get pods
NAME                                        READY   STATUS    RESTARTS   AGE
sample-python-deployment-7b67d95fdc-56p4g   1/1     Running   0          37s
sample-python-deployment-7b67d95fdc-5sdcx   1/1     Running   0          37s
sample-python-deployment-7b67d95fdc-5v2r8   1/1     Running   0          35s
sample-python-deployment-7b67d95fdc-74sb8   1/1     Running   0          35s
sample-python-deployment-7b67d95fdc-cs9px   1/1     Running   0          37s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;SSH into pod as see ENV variable: &lt;/li&gt;
&lt;li&gt;Notice: There is no environment variable - because &lt;code&gt;deploy_volume_mount.yaml&lt;/code&gt; file, since we removed it.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl exec -it sample-python-deployment-7b67d95fdc-56p4g -- /bin/bash
1011150000@sample-python-deployment-7b67d95fdc-56p4g:/app$ env | grep DB
NSS_SDB_USE_CACHE=no
1011150000@sample-python-deployment-7b67d95fdc-56p4g:/app$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Notice : volume is mounted on &lt;code&gt;/opt&lt;/code&gt; path and &lt;code&gt;port: 3307&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1011150000@sample-python-deployment-7b67d95fdc-56p4g:/app$ ls /opt
db-port
1011150000@sample-python-deployment-7b67d95fdc-56p4g:/app$ cat /opt/db-port | more
3307
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Change Port to &lt;code&gt;3308&lt;/code&gt; in &lt;code&gt;configmap.yml&lt;/code&gt; and apply
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: ConfigMap
metadata: 
  name: py-app-configmap
data: 
  db-port: "3308"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;apply changes: &lt;code&gt;Kubectl apply -f configmap.yml&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;describe configmap : &lt;code&gt;$ kubectl describe cm py-app-configmap&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl describe cm py-app-configmap
Name:         py-app-configmap
Namespace:    jasper475-dev
Labels:       &amp;lt;none&amp;gt;
Annotations:  &amp;lt;none&amp;gt;

Data
====
db-port:
----
3308

BinaryData
====

Events:  &amp;lt;none&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftj7vntmrvjuh4sq8g9y4.png" alt="Config Map: port 3308" width="800" height="438"&gt;
&lt;/li&gt;
&lt;li&gt;SSH into POD and get Port info - &lt;code&gt;kubectl exec -it sample-python-deployment-7b67d95fdc-56p4g -- /bin/bash&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl exec -it sample-python-deployment-7b67d95fdc-56p4g -- /bin/bash
groups: cannot find name for group ID 1011150000
1011150000@sample-python-deployment-7b67d95fdc-56p4g:/app$ env | grep DB
NSS_SDB_USE_CACHE=no
1011150000@sample-python-deployment-7b67d95fdc-56p4g:/app$ ls  /opt
db-port
1011150000@sample-python-deployment-7b67d95fdc-56p4g:/app$ cat /opt/db-port | more
3308
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Deploying &lt;strong&gt;ConfigMap&lt;/strong&gt; in Kubernetes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;create a &lt;code&gt;Secret&lt;/code&gt; via CLI command&lt;/li&gt;
&lt;li&gt;&lt;code&gt;kubectl create secret generic - to store passwords&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl create secret tls - to store certificates&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl create secret generic empty-secret
secret/empty-secret created

$ kubectl get secret empty-secret
NAME           TYPE     DATA   AGE
empty-secret   Opaque   0      19s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl create secret genericmy-db-secret --from-literal=db-port="3308"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create secret via &lt;code&gt;basic_secret.yaml&lt;/code&gt; file
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Secret
metadata:
  name: secret-basic-auth
type: kubernetes.io/basic-auth
stringData:
  username: admin # required field for kubernetes.io/basic-auth
  password: t0p-Secret # required field for kubernetes.io/basic-auth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;apply : &lt;code&gt;kubectl apply -f basicsecret.yaml&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl apply -f basic_secret.yaml                                     
secret/secret-basic-auth created
$  kubectl get secret secret-basic-auth
NAME                TYPE                       DATA   AGE
secret-basic-auth   kubernetes.io/basic-auth   2      17s
PS C:\Users\Jasper\OneDrive\Documents\CodeRepo\kubernetes\d41_ConfigMaps_Secrets&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Verify Secrets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm6rskd4y152ton5exhv5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm6rskd4y152ton5exhv5.png" alt="Secret create " width="800" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Describe &lt;code&gt;Secret&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl describe secret secret-basic-auth
Name:         secret-basic-auth
Namespace:    jasper475-dev
Labels:       &amp;lt;none&amp;gt;
Annotations:  &amp;lt;none&amp;gt;

Type:  kubernetes.io/basic-auth

Data
====
password:  10 bytes
username:  5 bytes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Edit secret: &lt;code&gt;kubectl edit secret secret-basic-auth&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
data:
  password: dDBwLVNlY3JldA==
  username: YWRtaW4=
kind: Secret
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Secret","metadata":{"annotations":{},"name":"secret-basic-auth","namespace":"jasper475-dev"},"stringData":{"password":"t0p-Secret","username":"admin"},"type":"kubernetes.io/basic-auth"}
  creationTimestamp: "2024-01-17T20:02:39Z"
  name: secret-basic-auth
  namespace: jasper475-dev
  resourceVersion: "1769551165"
  uid: 46bf94fa-c060-4f6b-83d6-9e08a4637b25
type: kubernetes.io/basic-auth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Verify Secrets: By default, they are encoded &lt;code&gt;Base64&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Jasper@JASPERS-PC MINGW64 ~/OneDrive/Documents/CodeRepo/kubernetes/d41_ConfigMaps_Secrets
$ echo dDBwLVNlY3JldA== | base64 --decode
t0p-Secret
Jasper@JASPERS-PC MINGW64 ~/OneDrive/Documents/CodeRepo/kubernetes/d41_ConfigMaps_Secrets
$ echo YWRtaW4= | base64 --decode
admin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Credits:-&lt;/strong&gt;&lt;br&gt;
Thanks to &lt;a href="https://www.youtube.com/@AbhishekVeeramalla"&gt;Abhishek Veeramalla&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>kubernetes</category>
      <category>configmap</category>
      <category>secrets</category>
    </item>
    <item>
      <title>Install/Setup - Service Mesh Capabilities via Istio on Kubernetes Cluster</title>
      <dc:creator>Jasper Rodda</dc:creator>
      <pubDate>Tue, 16 Jan 2024 15:35:27 +0000</pubDate>
      <link>https://forem.com/jasper475/installsetup-service-mesh-capabilities-via-istio-on-kubernetes-cluster-bb0</link>
      <guid>https://forem.com/jasper475/installsetup-service-mesh-capabilities-via-istio-on-kubernetes-cluster-bb0</guid>
      <description>&lt;h1&gt;
  
  
  1. What is a Service Mesh?
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Modern applications are typically architected as distributed collections of microservices, with each collection of microservices performing some discrete business function. A service mesh is a dedicated infrastructure layer that you can add to your applications. It allows you to transparently add capabilities like observability, traffic management, and security, without adding them to your own code. The term “service mesh” describes both the type of software you use to implement this pattern, and the security or network domain that is created when you use that software. click here to &lt;a href="https://istio.io/latest/about/service-mesh/"&gt;read more&lt;/a&gt;.&lt;/em&gt; &lt;/p&gt;

&lt;h1&gt;
  
  
  2. What is Istio?
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Istio is an open-source service mesh that layers transparently onto existing distributed applications. Istio’s powerful features provide a uniform and more efficient way to secure, connect, and monitor services. Istio is the path to load balancing, service-to-service authentication, and monitoring – with few or no service code changes. Its powerful control plane brings vital features, including:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Secure service-to-service communication in a cluster with TLS encryption, strong identity-based authentication and authorization&lt;/li&gt;
&lt;li&gt;Automatic load balancing for HTTP, gRPC, WebSocket, and TCP traffic&lt;/li&gt;
&lt;li&gt;Fine-grained control of traffic behavior with rich routing rules, retries, failovers, and fault injection&lt;/li&gt;
&lt;li&gt;A pluggable policy layer and configuration API supporting access controls, rate limits and quotas&lt;/li&gt;
&lt;li&gt;Automatic metrics, logs, and traces for all traffic within a cluster, including cluster ingress and egress
click here to &lt;a href="https://istio.io/latest/about/service-mesh/"&gt;read more&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Setup Istio on Kubernetes cluster
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Go to &lt;a href="https://istio.io/latest/docs/"&gt;istio.io&lt;/a&gt; and click on &lt;code&gt;Setup&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Click on &lt;a href="https://istio.io/latest/docs/setup/install/"&gt;Installation Guide&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Install with &lt;a href="https://istio.io/latest/docs/setup/install/helm/"&gt;Helm&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm repo add istio https://istio-release.storage.googleapis.com/charts
helm repo update

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;create namespace
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create namespace istio-system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install the Istio base chart &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;which contains cluster-wide Custom Resource Definitions (CRDs) which must be installed prior to the deployment of the Istio control plane:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm install istio-base istio/base -n istio-system --set defaultRevision=default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Validate the CRD installation with the helm ls command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ helm ls -n istio-system
NAME       NAMESPACE    REVISION UPDATED         STATUS   CHART         APP VERSION
istio-base istio-system 1        ... ... ... ... deployed base-1.16.1   1.16.1
istiod     istio-system 1        ... ... ... ... deployed istiod-1.16.1 1.16.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Get the status of the installed helm chart to ensure it is deployed:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ helm status istiod -n istio-system
NAME: istiod
LAST DEPLOYED: Fri Jan 20 22:00:44 2023
NAMESPACE: istio-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
"istiod" successfully installed!

To learn more about the release, try:
  $ helm status istiod
  $ helm get all istiod

Next steps:
  * Deploy a Gateway: https://istio.io/latest/docs/setup/additional-setup/gateway/
  * Try out our tasks to get started on common configurations:
    * https://istio.io/latest/docs/tasks/traffic-management
    * https://istio.io/latest/docs/tasks/security/
    * https://istio.io/latest/docs/tasks/policy-enforcement/
    * https://istio.io/latest/docs/tasks/policy-enforcement/
  * Review the list of actively supported releases, CVE publications and our hardening guide:
    * https://istio.io/latest/docs/releases/supported-releases/
    * https://istio.io/latest/news/security/
    * https://istio.io/latest/docs/ops/best-practices/security/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Check istiod service is successfully installed and its pods are running:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl get deployments -n istio-system --output wide
NAME     READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS   IMAGES                         SELECTOR
istiod   1/1     1            1           10m   discovery    docker.io/istio/pilot:1.16.1   istio=pilot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;(Optional) Install an ingress gateway:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl create namespace istio-ingress
$ helm install istio-ingress istio/gateway -n istio-ingress --wait
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>beginners</category>
      <category>istio</category>
      <category>kubernetes</category>
      <category>servicemesh</category>
    </item>
    <item>
      <title>Create Redhat Openshift -Shared Kubernetes Cluster - Free 30 Day Access</title>
      <dc:creator>Jasper Rodda</dc:creator>
      <pubDate>Mon, 15 Jan 2024 04:20:52 +0000</pubDate>
      <link>https://forem.com/jasper475/create-redhat-openshift-shared-kubernetes-cluster-free-30-day-access-oe</link>
      <guid>https://forem.com/jasper475/create-redhat-openshift-shared-kubernetes-cluster-free-30-day-access-oe</guid>
      <description>&lt;p&gt;What you'll do. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create RedHat Account.&lt;/li&gt;
&lt;li&gt;Open Developer Sandbox.&lt;/li&gt;
&lt;li&gt;Create Free 30-Day Shared OpenShift Kubernetes Cluster. &lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  1. Create Redhat Account.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Go to &lt;a href="https://developers.redhat.com/developer-sandbox"&gt;Redhat&lt;/a&gt; and register by giving your information.&lt;/li&gt;
&lt;li&gt;Provide Username, Email Id, Password, &lt;/li&gt;
&lt;li&gt;Verify Email - click on link in your email inbox to verify. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Open Developer Sandbox
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Click on &lt;a href="https://developers.redhat.com/developer-sandbox"&gt;Start your Sandbox for Free&lt;/a&gt; &lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5vyi387xvh1qa5a3f68e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5vyi387xvh1qa5a3f68e.png" alt="Image description" width="800" height="474"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Land on Page and click on &lt;a href="https://console.redhat.com/openshift/sandbox"&gt;Launch Red Hat OpenShift&lt;/a&gt; &lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhr1yinmztqh1zsonwfbi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhr1yinmztqh1zsonwfbi.png" alt="Image description" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  - Red Hat Developer Sandbox Has 3 services
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Red Hat OpenShift: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A cloud-native application platform with everything you need to manage your development life cycle securely, including standardized workflows, support for multiple environments, continuous integration, and release management.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Red Hat Dev Spaces&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A collaborative Kubernetes-native solution for rapid application development that delivers consistent developer environments on Red Hat OpenShift to allow anyone with a browser to contribute code in under two minutes.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Red Hat Data Science&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Red Hat OpenShift Data Science is a part of the Red Hat OpenShift AI portfolio and provides tools across the AI/ML lifecycle.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Click on Option 1: &lt;a href="https://oauth-openshift.apps.sandbox-m3.1530.p1.openshiftapps.com/oauth/authorize?client_id=console&amp;amp;redirect_uri=https%3A%2F%2Fconsole-openshift-console.apps.sandbox-m3.1530.p1.openshiftapps.com%2Fauth%2Fcallback&amp;amp;response_type=code&amp;amp;scope=user%3Afull&amp;amp;state=8a7615b6"&gt;Red Hat OpenShift&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;click on Login with DevSandbox
&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff6ha4u2ni0mliz1ikqj0.png" alt="Image description" width="800" height="488"&gt;
&lt;/li&gt;
&lt;li&gt;Developer Prespective &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmimy6jg7a75i7jcw3c5h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmimy6jg7a75i7jcw3c5h.png" alt="Image description" width="800" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Copy Login Command - Go to Top right corner of username dropdown and select option&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frbsfdef08hfvx4a9uun9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frbsfdef08hfvx4a9uun9.png" alt="Image description" width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://access.redhat.com/downloads/content/290/ver=4.14/rhel---9/4.14.8/x86_64/product-software"&gt;Download&lt;/a&gt; OpenShift CLI (oc) &lt;/li&gt;
&lt;li&gt;&lt;p&gt;Login via Command&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Login via this command: &lt;code&gt;oc login --token=sha256~123-elkjadsg-325o8-98739487 --server=https://api.sandbox-m3.1530.p1.openshiftapps.com:6443&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ oc login --token=sha256~123-elkjadsg-325o8-98739487 --server=https://api.sandbox-m3.1530.p1.openshiftapps.com:6443
Logged into "https://api.sandbox-m3.1530.p1.openshiftapps.com:6443" as "jasper475" using the token provided.

You have one project on this server: "jasper475-dev"

Using project "jasper475-dev".
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;use &lt;code&gt;Kubectl&lt;/code&gt; to interact with OpenShift Cluster. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Red Hat OpenShift Console
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Pods&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhmb9ljp429tbwxe6mfqc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhmb9ljp429tbwxe6mfqc.png" alt="Image description" width="800" height="332"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deployments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1bm2uuy91k53g2a1wswg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1bm2uuy91k53g2a1wswg.png" alt="Image description" width="800" height="227"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Replica Sets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmf9aho0wakt2prany3lr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmf9aho0wakt2prany3lr.png" alt="Image description" width="800" height="325"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftg6j3c5mkbcjf8n37jxc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftg6j3c5mkbcjf8n37jxc.png" alt="Image description" width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Routes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmxx4fngbcu6grf36yddm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmxx4fngbcu6grf36yddm.png" alt="Image description" width="800" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ingresses&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fax645gi9t6chllj6siw2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fax645gi9t6chllj6siw2.png" alt="Image description" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Credits:-&lt;/strong&gt;&lt;br&gt;
Thanks to &lt;a href="https://www.youtube.com/@AbhishekVeeramalla"&gt;Abhishek Veeramalla&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>openshift</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Install Ingress on Kubernetes and Minikube</title>
      <dc:creator>Jasper Rodda</dc:creator>
      <pubDate>Thu, 11 Jan 2024 23:23:00 +0000</pubDate>
      <link>https://forem.com/jasper475/install-ingress-on-kubernetes-and-minikube-gi2</link>
      <guid>https://forem.com/jasper475/install-ingress-on-kubernetes-and-minikube-gi2</guid>
      <description>&lt;p&gt;Kubernetes &lt;code&gt;ingress&lt;/code&gt; was introduced to overcome short comings of services. Another version of Kubernetes such as &lt;code&gt;Openshift&lt;/code&gt; created similar ingress such as &lt;code&gt;Routes&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Kubernetes Service - Drawbacks
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Missing Enterprise Grade Load Bancing Capabilities.&lt;/li&gt;
&lt;li&gt;Driving Cloud Cost - for Public IP Address&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Kubernetes service [svc] of type=[LoadBalancer] does not support enterprise grade Loadbancing capabilities but rather simple round robin fashion.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;To Solve this problem Kubernetes have asked Enterprise Load Balancers such as (&lt;a href="https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/"&gt;F5, NGINX, Ambassador, HA Proxy&lt;/a&gt; to name a few) to create &lt;a href="https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/"&gt;Ingress Controllers&lt;/a&gt; and user to create a Ingress resources. Its user's responsibilities&lt;/em&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Enterprise Load Balancer Offers Advanced Capabilities
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Ratio Based Routing&lt;/li&gt;
&lt;li&gt;Sticky Session Routing&lt;/li&gt;
&lt;li&gt;Host Based&lt;/li&gt;
&lt;li&gt;Path Based&lt;/li&gt;
&lt;li&gt;Domain Based&lt;/li&gt;
&lt;li&gt;White listing IP Addresses&lt;/li&gt;
&lt;li&gt;Black Listing IP Addresses&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Install NGINX controller in Kubernetes.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;minikube addons enable ingress&lt;/code&gt;to install on &lt;a href="https://kubernetes.github.io/ingress-nginx/deploy/#minikube"&gt;Minikube&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Verify &lt;code&gt;Ingress Controller&lt;/code&gt; installed or not
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$minikube addons enable ingress
* ingress is an addon maintained by Kubernetes. For any concerns contact minikube on GitHub.
You can view the list of minikube maintainers at: https://github.com/kubernetes/minikube/blob/master/OWNERS
  - Using image registry.k8s.io/ingress-nginx/controller:v1.8.1
  - Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230407
  - Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230407
* Verifying ingress addon...
* The 'ingress' addon is enabled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;verify by following command &lt;code&gt;kubectl get pods -A | grep nginx&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\Users\Jasper\OneDrive\Documents\CodeRepo\kubernetes\d38_ingress_ctrl&amp;gt; kubectl get pods -A
NAMESPACE       NAME                                        READY   STATUS      RESTARTS       AGE
default         sample-python-deployment-5787bd6b9f-656fn   1/1     Running     1 (16h ago)    20h
default         sample-python-deployment-5787bd6b9f-t9ttj   1/1     Running     1 (16h ago)    20h
ingress-nginx   ingress-nginx-admission-create-vcq7w        0/1     Completed   0              132m
ingress-nginx   ingress-nginx-admission-patch-g6szm         0/1     Completed   1              132m
ingress-nginx   ingress-nginx-controller-7799c6795f-qc9w5   1/1     Running     0              132m
kube-system     coredns-5d78c9869d-nscfc                    1/1     Running     3 (16h ago)    12d
kube-system     etcd-minikube                               1/1     Running     3 (16h ago)    12d
kube-system     kube-apiserver-minikube                     1/1     Running     3 (16h ago)    12d
kube-system     kube-controller-manager-minikube            1/1     Running     3 (16h ago)    12d
kube-system     kube-proxy-gzk52                            1/1     Running     3 (16h ago)    12d
kube-system     kube-scheduler-minikube                     1/1     Running     3 (16h ago)    12d
kube-system     storage-provisioner                         1/1     Running     12 (69m ago)   12d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Create Ingress Resource in Kubernetes.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Route &lt;code&gt;foo.bar.com&lt;/code&gt; to IP Addresses 
-- _(To mock it in local, in real time - we do not need to mock is as IP address is mapped to Domain Name by DNS) _&lt;/li&gt;
&lt;li&gt;Below &lt;a href="https://kubernetes.io/docs/concepts/services-networking/ingress/"&gt;ingress.yml&lt;/a&gt; file is to route &lt;code&gt;foo.bar.com&lt;/code&gt; to Service &lt;code&gt;sample-python-service&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: sample-python-service-ingress
spec:
  rules:
  - host: "foo.bar.com"
    http:
      paths:
      - pathType: Prefix
        path: "/bar"
        backend:
          service:
            name: sample-python-service
            port:
              number: 80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Create &lt;code&gt;Ingress&lt;/code&gt; resource &lt;code&gt;kubectl apply -f ingress.yml&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Notice: Nothing happens if you don't install kubernetes controller. Controller will watch for this resource to be created and they applies the logic.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl apply -f ingress.yml
ingress.networking.k8s.io/sample-python-service-ingress created
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Verify Ingress Resource in Kubernetes.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Run command &lt;code&gt;kubectl get ingress&lt;/code&gt; to view &lt;code&gt;ingress&lt;/code&gt; resource
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get ingress
NAME                            CLASS   HOSTS         ADDRESS          PORTS   AGE
sample-python-service-ingress   nginx   foo.bar.com   192.168.59.105   80      6m35s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Route domain to &lt;code&gt;Ingress&lt;/code&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Locate &lt;code&gt;Hosts File&lt;/code&gt; and update &lt;code&gt;config&lt;/code&gt; to point domain name &lt;code&gt;foo.bar.com&lt;/code&gt; to created &lt;code&gt;ingress-service&lt;/code&gt; --&amp;gt; which points to &lt;code&gt;service&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Where is the Hosts File &lt;a href="https://www.liquidweb.com/kb/edit-host-file-windows-10/#:~:text=Where%20is%20the%20Hosts%20File%20Located%3F%201%20Windows,-%20%22%2Fetc%2Fhosts%22%203%20Mac%20OS%20X%20-%20%22%2Fprivate%2Fetc%2Fhosts%22"&gt;Located&lt;/a&gt;?&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;The location of the hosts file will differ by operating system. The typical locations are noted below.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Windows 10 - "C:\Windows\System32\drivers\etc\hosts"
Linux - "/etc/hosts"
Mac OS X - "/private/etc/hosts"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Verify domain is routed to Application (Ingress-&amp;gt; Service-&amp;gt; App)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fco8k76qj5onicti33bhr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fco8k76qj5onicti33bhr.png" alt="Image description" width="800" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Credits:-&lt;/strong&gt;&lt;br&gt;
Thanks to &lt;a href="https://www.youtube.com/@AbhishekVeeramalla"&gt;Abhishek Veeramalla&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Create and expose Services in Kubernetes</title>
      <dc:creator>Jasper Rodda</dc:creator>
      <pubDate>Thu, 11 Jan 2024 06:36:41 +0000</pubDate>
      <link>https://forem.com/jasper475/create-and-expose-services-in-kubernetes-oi8</link>
      <guid>https://forem.com/jasper475/create-and-expose-services-in-kubernetes-oi8</guid>
      <description>&lt;p&gt;In Kubernetes, a service has following purposes/advantages.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Expose Application to outside world.&lt;/li&gt;
&lt;li&gt;Service Discovery: Labels and Selectors.&lt;/li&gt;
&lt;li&gt;LoadBalancer or NodePort Mode.&lt;/li&gt;
&lt;li&gt;Install &lt;a href="https://github.com/kubeshark/kubeshark/releases/tag/v52.0.0"&gt;Kubeshark&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Pre-requisites:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Create deploy.yml file&lt;/li&gt;
&lt;li&gt;Create service.yml file&lt;/li&gt;
&lt;li&gt;Deploy deploy.yml&lt;/li&gt;
&lt;li&gt;Deploy service.yml &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Expose Application to outside world
&lt;/h2&gt;

&lt;h5&gt;
  
  
  - a) Create &lt;code&gt;deploy.yml&lt;/code&gt; file as below.
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: apps/v1
kind: Deployment
metadata: 
  name: sample-python-deployment
  labels: 
    app: sample-python-app
spec: 
  replicas: 2
  selector: 
    matchLabels: 
      app: sample-python-app
  template: 
    metadata: 
      labels: 
        app: sample-python-app
    spec:
      containers:
      - name: python-app
        image: jasper475/d37-k8s-services-py-django-app:v2
        ports:
        - containerPort: 8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  - b) Create &lt;code&gt;service.yml&lt;/code&gt; file as below.
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Service
metadata:
  name: sample-python-service
spec:
  type: NodePort
  selector:
    app: sample-python-app
  ports:
    - port: 80
      targetPort: 8000
      nodePort: 30007
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  - c) Deploy &lt;code&gt;deploy.yml&lt;/code&gt; file as below.
&lt;/h5&gt;

&lt;p&gt;&lt;code&gt;kubectl apply -f deploy.yaml&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl apply -f deploy.yaml
deployment.apps/sample-python-deployment created

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  - d) Deploy &lt;code&gt;service.yml&lt;/code&gt; file as below.
&lt;/h5&gt;

&lt;p&gt;&lt;code&gt;kubectl apply -f service.yaml&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl apply -f deploy.yaml
service/sample-python-service configured

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  - e) NodePort service Type: service deployed as NodePort type
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get svc
NAME                    TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
kubernetes              ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        11d
sample-python-service   NodePort    10.103.136.137   &amp;lt;none&amp;gt;        80:30007/TCP   2s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  - f) Notice &lt;code&gt;IP&lt;/code&gt; Address of Pod: Notice &lt;code&gt;IP&lt;/code&gt; below
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl get pods -o wide
NAME                                        READY   STATUS    RESTARTS   AGE     IP            NODE       NOMINATED NODE   READINESS GATES
sample-python-deployment-5787bd6b9f-656fn   1/1     Running   0          3h54m   10.244.0.35   minikube   &amp;lt;none&amp;gt;           &amp;lt;none&amp;gt;
sample-python-deployment-5787bd6b9f-t9ttj   1/1     Running   0          3h50m   10.244.0.36   minikube   &amp;lt;none&amp;gt;           &amp;lt;none&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  - g) Access Application via &lt;code&gt;IP Addr:Port&lt;/code&gt;: Note, Python application is exposed via &lt;code&gt;Port 8000&lt;/code&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ minikube ssh
curl -L http://10.244.0.35:8000/demo ####Access via Pod IP Address  *** It works ***
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Service Discovery: Labels and Selectors.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Edit 'service.yml' file &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;FROM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; spec:
  type: NodePort
  selector:
    app: sample-python-app***
  ports:
    - port: 80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;TO&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;spec:
  type: NodePort
  selector:
    app: sample-python-a***
  ports:
    - port: 80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbv88pdf8fpoglrms115g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbv88pdf8fpoglrms115g.png" alt="Image description" width="800" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. LoadBalancer or NodePort Mode.
&lt;/h2&gt;

&lt;h4&gt;
  
  
  - a) get svc: &lt;code&gt;kubectl get svc&lt;/code&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl get svc                        
NAME                    TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
kubernetes              ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        11d
sample-python-service   NodePort    10.103.136.137   &amp;lt;none&amp;gt;        80:30007/TCP   33m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  - b) SVC Type: NodePort
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get svc
NAME                    TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
kubernetes              ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        11d
sample-python-service   NodePort    10.103.136.137   &amp;lt;none&amp;gt;        80:30007/TCP   2s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  - c) Access SVC: via NodePort Mode
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;minikube ssh
$ pwd
/home/docker
$ curl -L http://10.103.136.137:8000/demo ####Access via Cluster IP of svc on port 8000 - ******* Doesn't work*********
curl: (28) Failed to connect to 10.103.136.137 port 8000 after 131079 ms: Connection timed out
$ curl -L http://10.103.136.137:80/demo ####Access via Cluster IP of svc on port 80 - ******* Hurray, it works !!! *********
$ curl -L http://10.103.136.137:8000/demo ####Access via Pod IP Address

                         _             _
            _         _ ( )           ( )
  ___ ___  (_)  ___  (_)| |/')  _   _ | |_      __
/' _ ` _ `\| |/' _ `\| || , &amp;lt;  ( ) ( )| '_`\  /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )(  ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)

$ curl -L http://10.103.136.137:80
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta http-equiv="content-type" content="text/html; charset=utf-8"&amp;gt;
  &amp;lt;title&amp;gt;Page not found at /&amp;lt;/title&amp;gt;
  &amp;lt;meta name="robots" content="NONE,NOARCHIVE"&amp;gt;
  &amp;lt;style type="text/css"&amp;gt;
    html * { padding:0; margin:0; }
    body * { padding:10px 20px; }
    body * * { padding:0; }
    body { font:small sans-serif; background:#eee; color:#000; }
    body&amp;gt;div { border-bottom:1px solid #ddd; }
    h1 { font-weight:normal; margin-bottom:.4em; }
    h1 span { font-size:60%; color:#666; font-weight:normal; }
    table { border:none; border-collapse: collapse; width:100%; }
    td, th { vertical-align:top; padding:2px 3px; }
    th { width:12em; text-align:right; color:#666; padding-right:.5em; }
    #info { background:#f6f6f6; }
    #info ol { margin: 0.5em 4em; }
    #info ol li { font-family: monospace; }
    #summary { background: #ffc; }
    #explanation { background:#eee; border-bottom: 0px none; }
    pre.exception_value { font-family: sans-serif; color: #575757; font-size: 1.5em; margin: 10px 0 10px 0; }
  &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;div id="summary"&amp;gt;
    &amp;lt;h1&amp;gt;Page not found &amp;lt;span&amp;gt;(404)&amp;lt;/span&amp;gt;&amp;lt;/h1&amp;gt;

    &amp;lt;table class="meta"&amp;gt;
      &amp;lt;tr&amp;gt;
        &amp;lt;th&amp;gt;Request Method:&amp;lt;/th&amp;gt;
        &amp;lt;td&amp;gt;GET&amp;lt;/td&amp;gt;
      &amp;lt;/tr&amp;gt;
      &amp;lt;tr&amp;gt;
        &amp;lt;th&amp;gt;Request URL:&amp;lt;/th&amp;gt;
        &amp;lt;td&amp;gt;http://10.103.136.137/&amp;lt;/td&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  - d) Edit svc: &lt;code&gt;kubectl edit svc service-name&lt;/code&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl edit svc sample-python-service 
-------------------------------------------------------------------
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
kind: Service
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"sample-python-service","namespace":"default"},"spec":{"ports":[{"nodePort":30007,"port":80,"targetPort":8000}],"selector":{"app":"sample-python-app"},"type":"NodePort"}}
  creationTimestamp: "2024-01-11T02:51:02Z"
  name: sample-python-service
  namespace: default
  resourceVersion: "16469"
  uid: bd9bd510-e633-4dc1-adc1-1cc4704378d3
spec:
  allocateLoadBalancerNodePorts: true
  clusterIP: 10.103.136.137
  clusterIPs:
  - 10.103.136.137
  externalTrafficPolicy: Cluster
  internalTrafficPolicy: Cluster
  ipFamilies:
  - IPv4
  ipFamilyPolicy: SingleStack
  ports:
  - nodePort: 30007
    port: 80
    protocol: TCP
    targetPort: 8000
  selector:
    app: sample-python-app
  sessionAffinity: None
  type: ***LoadBalancer***
status:
  loadBalancer: {}
-------------------------------------------------------------------
service/sample-python-service edited
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;SVC Type: LoadBalancer - notice &lt;code&gt;EXTERNAL-IP&lt;/code&gt; is &lt;code&gt;&amp;lt;pending&amp;gt;&lt;/code&gt; state. Because, in Minikube this won't be creating an IP address whereas, in any cloud providers such as AWS EC2 or Azure VM or GCP Engine - &lt;code&gt;EXTERNAL-IP&lt;/code&gt; will be assigned via &lt;code&gt;Cloud-Control Manager&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get svc
NAME                    TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
kubernetes              ClusterIP      10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        11d
sample-python-service   LoadBalancer   10.103.136.137   &amp;lt;pending&amp;gt;     80:30007/TCP   34m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Get `Minikube ip'
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
$ minikube ip&lt;br&gt;
192.168.59.105&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Access via browser &lt;a href="http://192.168.59.105:30007/demo"&gt;http://192.168.59.105:30007/demo&lt;/a&gt;&lt;br&gt;
or curl -L &lt;a href="http://192.168.59.105:30007/demo"&gt;http://192.168.59.105:30007/demo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw99s1zv4dpuschmkf5oh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw99s1zv4dpuschmkf5oh.png" alt="Image description" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Install Kubeshark
&lt;/h2&gt;

&lt;h4&gt;
  
  
  - a) Install Kubeshark as below
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;git clone: git clone https://github.com/kubeshark/kubeshark&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
PS C:\Users\Jasper&amp;gt; git clone https://github.com/kubeshark/kubeshark&lt;br&gt;
Cloning into 'kubeshark'...&lt;br&gt;
remote: Enumerating objects: 20781, done.&lt;br&gt;
remote: Counting objects: 100% (1668/1668), done.&lt;br&gt;
remote: Compressing objects: 100% (262/262), done.&lt;br&gt;
remote: Total 20781 (delta 1525), reused 1491 (delta 1406), pack-reused 19113&lt;br&gt;
Receiving objects: 100% (20781/20781), 26.38 MiB | 19.53 MiB/s, done.&lt;br&gt;
Resolving deltas: 100% (14618/14618), done.&lt;br&gt;
PS C:\Users\Jasper&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Install Kubernetes Controllers via Operators - ARGO CD</title>
      <dc:creator>Jasper Rodda</dc:creator>
      <pubDate>Tue, 07 Nov 2023 22:38:54 +0000</pubDate>
      <link>https://forem.com/jasper475/install-kubernetes-controllers-via-operators-argo-cd-6jn</link>
      <guid>https://forem.com/jasper475/install-kubernetes-controllers-via-operators-argo-cd-6jn</guid>
      <description>&lt;h3&gt;
  
  
  Install Operator
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to &lt;a href="https://operatorhub.io/operator/argocd-operator"&gt;operatorhub.io&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Install Operator
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.26.0/install.sh | bash -s v0.26.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install ArgoCD Operator &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl create -f https://operatorhub.io/install/argocd-operator.yaml&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; kubectl create -f https://operatorhub.io/install/argocd-operator.yaml
subscription.operators.coreos.com/my-argocd-operator created

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Verify ArgoCD Operator Installed or not&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl get csv -n operators&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; kubectl get csv -n operators
NAME                     DISPLAY   VERSION   REPLACES                 PHASE
argocd-operator.v0.7.0   Argo CD   0.7.0     argocd-operator.v0.6.0   Pending
argocd-operator.v0.7.0   Argo CD   0.7.0     argocd-operator.v0.6.0   Installing
argocd-operator.v0.7.0   Argo CD   0.7.0     argocd-operator.v0.6.0   Succeeded
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Create ARGOCD Controller: Use manifest to create a new Argo CD cluster&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;source: &lt;a href="https://argocd-operator.readthedocs.io/en/latest/"&gt;ARGOCD documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go to Usage &amp;gt; Basic &amp;gt; save below in argo-cd-manifest.yml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: argoproj.io/v1alpha1
kind: ArgoCD
metadata:
  name: my-argocd
  labels:
    example: basic
spec: {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Warning: ArgoCD v1alpha1 version is deprecated and will be converted to v1beta1 automatically. Moving forward, please use v1beta1 as the ArgoCD API version.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Run Manifest command &lt;code&gt;kubectl apply -f argo-cd-manifest.yml&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl apply -f argo-cd-manifest.yml
$ kubectl apply -f argoctl.yml
argocd.argoproj.io/my-argocd created
OR 
argocd.argoproj.io/example-argocd created
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Verify operator pods are created &lt;code&gt;kubectl get pods&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; kubectl get pods
NAME                                          READY   STATUS    RESTARTS       AGE
my-argocd-application-controller-0       1/1     Running   3              21h
my-argocd-redis-6b8667cdb8-jnmm6         1/1     Running   2 (31m ago)    21h
my-argocd-repo-server-5d547c6f69-mgsnn   1/1     Running   22 (31m ago)   21h
my-argocd-server-bbdf5fdff-ccc2w         1/1     Running   23 (19h ago)   21h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Get service server Run list of services &lt;code&gt;kubectl get svc&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expose &lt;code&gt;my-argocd-server&lt;/code&gt; from &lt;code&gt;ClusterIP&lt;/code&gt; to &lt;code&gt;NodePort&lt;/code&gt; to access via browser&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;kubectl edit svc my-argocd-server&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; kubectl edit svc example-argocd-server
service/example-argocd-server edited
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; kubectl get svc
NAME                            TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
example-argocd-metrics          ClusterIP   10.106.206.190   &amp;lt;none&amp;gt;        8082/TCP                     21h
example-argocd-redis            ClusterIP   10.98.228.6      &amp;lt;none&amp;gt;        6379/TCP                     21h
example-argocd-repo-server      ClusterIP   10.104.167.116   &amp;lt;none&amp;gt;        8081/TCP,8084/TCP            21h
example-argocd-server           NodePort    10.108.236.251   &amp;lt;none&amp;gt;        80:30904/TCP,443:31659/TCP   21h
example-argocd-server-metrics   ClusterIP   10.104.220.61    &amp;lt;none&amp;gt;        8083/TCP                     21h
kubernetes                      ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP                      22h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Get the list of services and its URL to open in browser
&lt;code&gt;minikube service list&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; minikube service list
|-------------|----------------------------------------------------|--------------|-----------------------------|
|  NAMESPACE  |                        NAME                        | TARGET PORT  |             URL             |
|-------------|----------------------------------------------------|--------------|-----------------------------|
| default     | example-argocd-metrics                             | No node port |                             |
| default     | example-argocd-redis                               | No node port |                             |
| default     | example-argocd-repo-server                         | No node port |                             |
| default     | example-argocd-server                              | http/80      | http://192.168.59.102:30904 |
|             |                                                    | https/443    | http://192.168.59.102:31659 |
| default     | example-argocd-server-metrics                      | No node port |                             |
| default     | kubernetes                                         | No node port |                             |
| default     | spring-boot-app-service                            | http/80      | http://192.168.39.101:30296 |
| kube-system | kube-dns                                           | No node port |                             |
| olm         | operatorhubio-catalog                              | No node port |                             |
| olm         | packageserver-service                              | No node port |                             |
| operators   | argocd-operator-controller-manager-metrics-service | No node port |                             |
|-------------|----------------------------------------------------|--------------|-----------------------------|
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Open browser and access via local server/port forwarded &lt;a href="http://192.168.59.102:32600"&gt;http://192.168.59.102:32600&lt;/a&gt; as seen in below picture.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqixjdoajnku2efbq7icj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqixjdoajnku2efbq7icj.png" alt="Image description" width="800" height="607"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enter: username=admin password=''&lt;/li&gt;
&lt;li&gt;To get password run &lt;/li&gt;
&lt;li&gt; &lt;code&gt;kubectl get secret&lt;/code&gt; - secret is stored in &lt;code&gt;my-argocd-cluster&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt; &lt;code&gt;kubectl edit secret my-argocd-cluster&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; kubectl get secret
NAME                               TYPE                DATA   AGE
argocd-secret                      Opaque              5      11m
my-argocd-ca                       kubernetes.io/tls   3      11m
my-argocd-cluster                  Opaque              1      11m
my-argocd-default-cluster-config   Opaque              4      11m
my-argocd-tls                      kubernetes.io/tls   2      11m
PS C:\WINDOWS\system32&amp;gt; kubectl edit secret my-argocd-cluster
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;By default, password in store in base64 encoded format, run below command to get password from base64 encode to text&lt;/li&gt;
&lt;li&gt;convert base64 to plain text &lt;/li&gt;
&lt;li&gt;&lt;code&gt;echo echo enlkaXd1UEZCNVhoSXJUNGo3UXBvMkpNV2dTdmFaOUU= | base64 -d&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://stackoverflow.com/questions/68297354/what-is-the-default-password-of-argocd"&gt;To reset password&lt;/a&gt; to &lt;code&gt;password&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#bcrypt(password)=$2a$10$rRyBsGSHK6.uc8fntPwVIuLVHgsAhAX7TcdrqW/RADU0uh7CaChLa
kubectl -n argocd patch secret argocd-secret \
  -p '{"stringData": {
    "admin.password": "$2a$10$rRyBsGSHK6.uc8fntPwVIuLVHgsAhAX7TcdrqW/RADU0uh7CaChLa",
    "admin.passwordMtime": "'$(date +%FT%T%Z)'"
  }}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; kubectl get secret
NAME                                    TYPE                DATA   AGE
argocd-secret                           Opaque              5      22h
example-argocd-ca                       kubernetes.io/tls   3      22h
example-argocd-cluster                  Opaque              1      22h
example-argocd-default-cluster-config   Opaque              4      22h
example-argocd-tls                      kubernetes.io/tls   2      22h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  ARGO CD - App configuration:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Dashboard&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftkntapdtcbewzpligdm9.png" alt="Image description" width="800" height="626"&gt;
&lt;/h2&gt;

</description>
      <category>beginners</category>
      <category>kubernetescontroller</category>
      <category>argocd</category>
      <category>operators</category>
    </item>
    <item>
      <title>How to Login/Authenticate Terraform via Azure CLI</title>
      <dc:creator>Jasper Rodda</dc:creator>
      <pubDate>Thu, 19 Oct 2023 19:24:14 +0000</pubDate>
      <link>https://forem.com/jasper475/how-to-loginauthenticate-terraform-via-azure-cli-f49</link>
      <guid>https://forem.com/jasper475/how-to-loginauthenticate-terraform-via-azure-cli-f49</guid>
      <description>&lt;p&gt;There are multiple ways for authenticating.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/azure_cli"&gt;Authenticating to Azure using the Azure CLI&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/managed_service_identity"&gt;Authenticating to Azure using Managed Service Identity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/service_principal_client_certificate"&gt;Authenticating to Azure using a Service Principal and a Client Certificate&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/service_principal_client_secret"&gt;Authenticating to Azure using a Service Principal and a Client Secret&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/service_principal_oidc"&gt;Authenticating to Azure using a Service Principal and Open ID Connect&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Official Terraform documentation recommends authenticating via Azure CLI when using locally and They recommend using either a Service Principal or Managed Service Identity when running Terraform non-interactively (such as when running Terraform in a CI server) &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Pre-requisites&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install Azure CLI&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 1: Login
&lt;/h2&gt;

&lt;p&gt;Login using powershell and use command &lt;code&gt;az login&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Microsoft prompt
&lt;/h2&gt;

&lt;p&gt;A prompt is opened in browser, and you can login using the credentials. &lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: PowerShell Json Response
&lt;/h2&gt;

&lt;p&gt;Notice you will get below response after authorization.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\Users\Jasper&amp;gt; az login
A web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`.
[
  {
    "cloudName": "AzureCloud",
    "homeTenantId": "3hfdg567-4564-6u78-k898-asdgesr34523",
    "id": "3hfdg567-4564-6u78-k898-asde8sr34523",
    "isDefault": true,
    "managedByTenants": [],
    "name": "Azure subscription 1",
    "state": "Enabled",
    "tenantId": "3hfdg567-4564-6u78-k898-asdgesr34523",
    "user": {
      "name": "pemail@gmail.com",
      "type": "user"
    }
  }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Install Azure CLI using Powershell on Windows</title>
      <dc:creator>Jasper Rodda</dc:creator>
      <pubDate>Thu, 19 Oct 2023 17:11:51 +0000</pubDate>
      <link>https://forem.com/jasper475/install-azure-cli-using-powershell-on-windows-c</link>
      <guid>https://forem.com/jasper475/install-azure-cli-using-powershell-on-windows-c</guid>
      <description>&lt;p&gt;If you want to interact with Microsoft Azure resources from your machine, you need an Azure CLI installed. &lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Pre-Requisites: *&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Host Laptop (Windows, Mac, Linux)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://learn.microsoft.com/en-us/cli/azure/install-azure-cli"&gt;Azure CLI&lt;/a&gt; Installation documentation. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this tutorial, I will share specific steps for installing Azure CLI using PowerShell.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Installation using Powershell
&lt;/h2&gt;

&lt;p&gt;Open PowerShell and copy paste the following commands&lt;/p&gt;

&lt;h2&gt;
  
  
  - For Windows 32 Bit 
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; Remove-Item .\AzureCLI.msi&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  - For Windows 64 Bit
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -Uri https://aka.ms/installazurecliwindowsx64 -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; Remove-Item .\AzureCLI.msi&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Verify Installation
&lt;/h2&gt;

&lt;p&gt;you can enter in powershell by typing 'az --version' &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;az --version&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; az --version
azure-cli                         2.53.0

core                              2.53.0
telemetry                          1.1.0

Dependencies:
msal                            1.24.0b2
azure-mgmt-resource             23.1.0b2

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you see this post - that's it. you are able to install Azure CLI successfully.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Update the Azure CLI Uninstall
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;type - &lt;code&gt;az upgrade&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\WINDOWS\system32&amp;gt; az upgrade
This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
You already have the latest azure-cli version: 2.53.0
Upgrade finished.You can enable auto-upgrade with 'az config set auto-upgrade.enable=yes'. More details in https://docs.microsoft.com/cli/azure/update-azure-cli#automatic-update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Uninstall Azure CLI
&lt;/h2&gt;

&lt;p&gt;Platform    Instructions&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows 11    Start &amp;gt; Settings &amp;gt; Apps &amp;gt; Installed apps&lt;/li&gt;
&lt;li&gt;Windows 10    Start &amp;gt; Settings &amp;gt; System &amp;gt; Apps &amp;amp; Features&lt;/li&gt;
&lt;li&gt;Windows 8 and Windows 7   Start &amp;gt; Control Panel &amp;gt; Programs &amp;gt; Uninstall a program&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
  </channel>
</rss>
