<?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>DEV Community: Martin Mwangi</title>
    <description>The latest articles on DEV Community by Martin Mwangi (@martwebber).</description>
    <link>https://dev.to/martwebber</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F873019%2F71b5727c-1ac2-445d-a0cd-53ec2514aa6f.png</url>
      <title>DEV Community: Martin Mwangi</title>
      <link>https://dev.to/martwebber</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/martwebber"/>
    <language>en</language>
    <item>
      <title>Infrastructure GitOps: A Step-by-Step Guide to Setting Up Your Test Cluster Locally using minikube for Seamless Exploration</title>
      <dc:creator>Martin Mwangi</dc:creator>
      <pubDate>Thu, 21 Dec 2023 22:26:46 +0000</pubDate>
      <link>https://dev.to/martwebber/infrastructure-gitops-a-step-by-step-guide-to-setting-up-your-test-cluster-locally-using-minikube-for-seamless-exploration-3471</link>
      <guid>https://dev.to/martwebber/infrastructure-gitops-a-step-by-step-guide-to-setting-up-your-test-cluster-locally-using-minikube-for-seamless-exploration-3471</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Explore the power of Crossplane Infrastructure through GitOps as I guide you in setting up a Crossplane Management Cluster on a local Minikube cluster. Follow this comprehensive tutorial to create and manage AWS resources seamlessly within your Kubernetes environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites for setting up Crossplane
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A Kubernetes cluster with at least 2 GB of RAM&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Permissions to create pods and secrets in the Kubernetes cluster&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Helm version v3.2.0 or later&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An AWS account with permissions to create an S3 storage bucket&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;AWS access keys&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 1: A Kubernetes cluster with at least 2 GB of RAM&lt;/strong&gt;&amp;nbsp;&lt;br&gt;
We will use Minikube to set up a Kubernetes cluster locally on Ubuntu - x86-64. If your setup is different, visit &lt;a href="https://minikube.sigs.k8s.io/docs/start/" rel="noopener noreferrer"&gt;https://minikube.sigs.k8s.io/docs/start/&lt;/a&gt;  to download the binary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install the latest minikube stable release:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Start minikube:&lt;/strong&gt;&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
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the current user to the docker group and then start a new shell with the updated group membership using the command below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo usermod -aG docker $USER &amp;amp;&amp;amp; newgrp docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If minikube fails to start, setup docker as your driver using the commands below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Start a cluster using the docker driver:&lt;/strong&gt;&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=docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make docker the default driver&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;minikube config set driver docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Interact with the cluster:&lt;/strong&gt;&lt;br&gt;
If you already have kubectl installed to get pods&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get po -A
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you don’t have kubectl installed, use the command below to set it up and get pods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;minikube kubectl -- get po -A
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Install Helm&lt;/strong&gt;&lt;br&gt;
Use the commands below to install helm locally using a bash script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Install Crossplane&lt;/strong&gt;&lt;br&gt;
Add the Crossplane Helm repository:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Update the local Helm chart cache:&lt;/strong&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 repo update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install the Crossplane helm chart:&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 crossplane \
--namespace crossplane-system \
--create-namespace crossplane-stable/crossplane
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the Helm dry-run to see all the Crossplane components Helm installs.&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 crossplane \
crossplane-stable/crossplane \
--dry-run --debug \
--namespace crossplane-system \
--create-namespace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Install the Crossplane components:&lt;/strong&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 crossplane \
crossplane-stable/crossplane \
--namespace crossplane-system \
--create-namespace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Verify if Crossplane is installed:&lt;/strong&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 get pods -n crossplane-system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;View all the end-points created when Crossplane is installed:&lt;/strong&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 api-resources | grep crossplane
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Install the AWS provider&lt;/strong&gt; &lt;br&gt;
Install the AWS provider into the Kubernetes cluster with a Kubernetes configuration file. You can choose your provider based on the managed resource you want o provision. We will install AWS S3 provider which provisions S3 managed resource&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat &amp;lt;&amp;lt;EOF | kubectl apply -f -
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
&amp;nbsp;&amp;nbsp;name: provider-aws-s3
spec:
&amp;nbsp;&amp;nbsp;package: xpkg.upbound.io/upbound/provider-aws-s3:v0.37.0
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify the provider installed with kubectl get providers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get providers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add your access key and secret to a text file aws-credentials.txt&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[default]
aws_access_key_id = &amp;lt;access key&amp;gt;
aws_secret_access_key = &amp;lt;secret key&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a Kubernetes secret with the AWS credentials&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 \
generic aws-secret \
-n crossplane-system \
--from-file=creds=./aws-credentials.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;View kubernetes secret&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl describe secret aws-secret -n crossplane-system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a ProviderConfig: a ProviderConfig customizes the settings of the AWS Provider. Apply the ProviderConfig with this Kubernetes configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat &amp;lt;&amp;lt;EOF | kubectl apply -f -
apiVersion: aws.upbound.io/v1beta1
kind: ProviderConfig
metadata:
&amp;nbsp;&amp;nbsp;name: default
spec:
&amp;nbsp;&amp;nbsp;credentials:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;source: Secret
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;secretRef:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;namespace: crossplane-system
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;name: aws-secret
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;key: creds
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Create a managed resource:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bucket=$(echo "crossplane-bucket-"$(head -n 4096 /dev/urandom | openssl sha1 | tail -c 10))
cat &amp;lt;&amp;lt;EOF | kubectl apply -f -
apiVersion: s3.aws.upbound.io/v1beta1
kind: Bucket
metadata:
&amp;nbsp;&amp;nbsp;name: $bucket
spec:
&amp;nbsp;&amp;nbsp;forProvider:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;region: us-east-2
&amp;nbsp;&amp;nbsp;providerConfigRef:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;name: default
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A managed resource is anything Crossplane creates and manages outside of the Kubernetes cluster.&lt;br&gt;
&lt;strong&gt;Verify crossplane has created an S3 bucket:&lt;/strong&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 get buckets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Minikube: &lt;a href="https://minikube.sigs.k8s.io/docs/start/" rel="noopener noreferrer"&gt;https://minikube.sigs.k8s.io/docs/start/&lt;/a&gt; &amp;nbsp;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Crossplane: &lt;a href="https://docs.crossplane.io/v1.14/software/install/" rel="noopener noreferrer"&gt;https://docs.crossplane.io/v1.14/software/install/&lt;/a&gt; &amp;nbsp;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Providers: &lt;a href="https://marketplace.upbound.io/providers" rel="noopener noreferrer"&gt;https://marketplace.upbound.io/providers&lt;/a&gt; &amp;nbsp;&lt;br&gt;
Getting started with AWS provider: &lt;a href="https://docs.crossplane.io/v1.13/getting-started/provider-aws/" rel="noopener noreferrer"&gt;https://docs.crossplane.io/v1.13/getting-started/provider-aws/&lt;/a&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Crossplane youtube playlist by Viktor Farcic:&amp;nbsp;&lt;a href="https://www.youtube.com/watch?v=AtbS1u2j7po&amp;amp;list=PLyicRj904Z9_X62k6_XM_xlJkSyoQDkS2&amp;amp;ab_channel=DevOpsToolkit" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=AtbS1u2j7po&amp;amp;list=PLyicRj904Z9_X62k6_XM_xlJkSyoQDkS2&amp;amp;ab_channel=DevOpsToolkit&lt;/a&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Upbound official crossplane documentation: &lt;a href="https://docs.upbound.io/" rel="noopener noreferrer"&gt;https://docs.upbound.io/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>crossplane</category>
      <category>gitops</category>
      <category>aws</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
