<?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>The Ops Community ⚙️: Tracy Holmes</title>
    <description>The latest articles on The Ops Community ⚙️ by Tracy Holmes (@tracypholmes).</description>
    <link>https://community.ops.io/tracypholmes</link>
    <image>
      <url>https://community.ops.io/images/L-TVy_-Zosn9EpXWivFhTOxArYGtAKA2G3_cY4nCKNQ/rs:fill:90:90/g:sm/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL3Vz/ZXIvcHJvZmlsZV9p/bWFnZS81Ny8zMzM0/YzY4ZS0yZWQyLTQz/YTktYWQ3Yi05NjY0/YzJjZTZjZDQuanBn</url>
      <title>The Ops Community ⚙️: Tracy Holmes</title>
      <link>https://community.ops.io/tracypholmes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://community.ops.io/feed/tracypholmes"/>
    <language>en</language>
    <item>
      <title>Getting Started with GitOps and Argo CD</title>
      <dc:creator>Tracy Holmes</dc:creator>
      <pubDate>Wed, 25 May 2022 18:23:27 +0000</pubDate>
      <link>https://community.ops.io/tracypholmes/getting-started-with-gitops-and-argo-cd-3cjo</link>
      <guid>https://community.ops.io/tracypholmes/getting-started-with-gitops-and-argo-cd-3cjo</guid>
      <description>&lt;p&gt;Today we are going to explore getting started using Argo CD. This post is going to assume you know a bit about containers, and that you already have an empty cluster in place (or know how to create one). If any of this is unfamiliar, head over to &lt;a href="https://argo-cd.readthedocs.io/en/stable/understand_the_basics/"&gt;Understanding the Basics&lt;/a&gt; to get a bit of practice. Before we get started, let’s talk about GitOps.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is GitOps?
&lt;/h2&gt;

&lt;p&gt;If you are not familiar with GitOps, head over to &lt;a href="https://opengitops.dev/"&gt;https://opengitops.dev&lt;/a&gt; which is the official page of the GitOps working group. In short, GitOps is a paradigm that incorporates best practices applied to the application development workflow all the way to the operating infrastructure of a system. The principles of GitOps are the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The system is described in a declarative manner.&lt;/li&gt;
&lt;li&gt;The definition of the system is versioned and audited. This tends to be Git.&lt;/li&gt;
&lt;li&gt;A software agent automatically pulls the Git state and matches the platform state.&lt;/li&gt;
&lt;li&gt;The state is continuously reconciled. This means that any changes happening in Git should also be reflected in the system.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A GitOps tool that follows this approach of a Git-based workflow is Argo CD. It’s a continuous delivery tool for Kubernetes that is essentially a GitOps controller that does two-way synchronization. Argo continuously monitors running applications, compares the live state against the desired state in Git, and applies it to the cluster. Please note this monitoring is for both directions: Git &amp;gt; cluster AND cluster &amp;gt; Git!&lt;/p&gt;

&lt;p&gt;GitOps relies on Git as the single source of truth for declarative configuration and active reconciliation. What does this mean?&lt;/p&gt;

&lt;p&gt;This means Argo CD implements active reconciliation by automatically monitoring your cluster and detecting any manual changes that are not in the Git state. Adopting the GitOps methodology provides transparency between the application configuration deployed in a cluster and the one residing in Git.&lt;/p&gt;

&lt;p&gt;Additionally, some benefits of GitOps are deploying faster and more often, easier and quicker error handling and recovery, and self-documenting deployments. And most importantly? You also get the complete elimination of configuration drift. These benefits make it easier to handle the applications and allow teams to deliver quality software faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;For this exercise, you can absolutely use a local cluster such as Docker Desktop, minikube, k3s, etc. And if you have access to a cloud cluster? That’s even better.&lt;/p&gt;

&lt;p&gt;However, if you don’t have access to those things, let's make sure we have &lt;a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/"&gt;kubectl&lt;/a&gt; installed. &lt;code&gt;kubectl&lt;/code&gt; is a Kubernetes command-line tool that allows you to run commands against Kubernetes clusters.&lt;/p&gt;

&lt;p&gt;We also need a &lt;code&gt;kubeconfig&lt;/code&gt; file. If you already have an empty cluster, then that part of things has most likely already been done for you! In case you want to check, the default location for the config file is &lt;code&gt;~/.kube/config&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Argo CD
&lt;/h2&gt;

&lt;p&gt;Let’s start off by installing Argo CD. To do this, we’ll first create a new namespace, &lt;code&gt;argocd&lt;/code&gt;, where Argo CD services and application resources will live.&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 namespace argocd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, let’s apply our resource configuration file on the &lt;code&gt;argocd&lt;/code&gt; namespace we just created.&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 -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once your installation completes, you can use the watch command to check the status of your Kubernetes pods and make sure they are ready.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;watch kubectl get pods -n argocd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since we are using a stock Argo CD installation, you should see five pods with a &lt;code&gt;Running&lt;/code&gt; status.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NAME                                  READY   STATUS    RESTARTS   AGE
argocd-redis-d486999b7-cd275          1/1     Running   0          8m57s
argocd-dex-server-65bf5f4fc7-p6kv8    1/1     Running   0          8m57s
argocd-repo-server-8465d84869-z4mqb   1/1     Running   0          8m57s
argocd-application-controller-0       1/1     Running   0          8m56s
argocd-server-87b47d787-pbnw8         1/1     Running   0          8m57s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once things are up and running, you can use &lt;code&gt;Ctrl+C&lt;/code&gt; to exit the watch interface. This is only one of the possible ways to install Argo CD! You are also able to use a &lt;a href="https://argo-cd.readthedocs.io/en/stable/user-guide/helm/"&gt;Helm chart&lt;/a&gt; or a smart installer like &lt;a href="https://argocd-autopilot.readthedocs.io/en/stable/"&gt;Argo Autopilot&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Access The Argo CD API Server
&lt;/h2&gt;

&lt;p&gt;By default, the Argo CD API server is not exposed with an external IP. For the purposes of this post, we are going to utilize kubectl port-forwarding to connect to the API server without actually exposing the service. We do that using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl port-forward svc/argocd-server -n argocd 8080:443
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will make things easier for us as we can now access the API server using &lt;code&gt;localhost:8080&lt;/code&gt;. &lt;strong&gt;Note&lt;/strong&gt;: this method is only for local development or demonstration purposes.&lt;/p&gt;

&lt;p&gt;There are two other techniques you can use to access the API server: Service Type Load Balancer and Ingress. If you’d like to learn more about those methods, definitely check out the &lt;a href="https://argo-cd.readthedocs.io/en/stable/operator-manual/ingress/"&gt;Getting Started&lt;/a&gt; guide for more information.&lt;/p&gt;

&lt;h2&gt;
  
  
  Download Argo CD CLI
&lt;/h2&gt;

&lt;p&gt;Now that we’ve gotten Argo CD downloaded, installed, and configured for access, it is time to login. There are two ways we can get this done: via the UI (or web interface) and the CLI. The UI and the CLI are mostly similar in capabilities. The CLI is great for changing settings and working with your Argo CD instance. Also, while you can deploy an application using the web interface, it’s typically quicker to deploy via the command line. I tend to use both depending on what I need. We will use both throughout this post.&lt;/p&gt;

&lt;p&gt;I also work across different operating systems, so &lt;a href="https://brew.sh/"&gt;Homebrew&lt;/a&gt; is usually my goto installation method as it is available for Linux, Mac, and WSL. To install Argo CD using Homebrew, you will use the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install argocd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and check that it has installed correctly using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;argocd version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also download the latest Argo CD version from &lt;a href="https://github.com/argoproj/argo-cd/releases/latest"&gt;https://github.com/argoproj/argo-cd/releases/latest&lt;/a&gt;. If you run into any issues, more detailed installation instructions can be found via the &lt;a href="https://argo-cd.readthedocs.io/en/stable/cli_installation/"&gt;CLI installation documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Login Using The CLI
&lt;/h2&gt;

&lt;p&gt;We are going to login using an admin account. The initial password for this account is auto-generated and stored in your namespace as clear text in the field password and in a secret named &lt;code&gt;argocd-initial-admin-secret&lt;/code&gt;. Let’s retrieve this password using &lt;code&gt;kubectl&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 -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d &amp;amp;&amp;amp; echo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I’ve added &lt;code&gt;&amp;amp;&amp;amp; echo&lt;/code&gt; to the end of that command to make it easier for us to copy &amp;amp; paste the generated password. Make sure to save it, as we will need it in the next steps.&lt;/p&gt;

&lt;p&gt;Now that we have that password, we can login! So, let’s do that using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;argocd login &amp;lt;ARGOCD_SERVER&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will substitute Argo CD’s IP or hostname where you see &lt;code&gt;&amp;lt;ARGOCD_SERVER&amp;gt;&lt;/code&gt; in that command. Remember when we set up port forwarding for easy access earlier in this post? Now it will come in handy!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;argocd login localhost:8080
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will prompt you for a username and password. The default username is &lt;code&gt;admin&lt;/code&gt;, and the password is the one we exposed up above. You will not see the password while entering it.&lt;/p&gt;

&lt;p&gt;We also want to change the password while we’re here as the generated one was in cleartext, and that’s not safe. The following command will ask you for your current password, the new password you’d like to use, and lastly, to confirm the new password.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;argocd account update-password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you do so, make sure to place your new password somewhere safe, as you will need it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create An Application From A Git Repository
&lt;/h2&gt;

&lt;p&gt;In order for us to create an application to demonstrate how Argo CD works, we are going to use an example repository containing a guestbook application. If you would like to check it out or follow along, it is available at &lt;a href="https://github.com/argoproj/argocd-example-apps.git"&gt;https://github.com/argoproj/argocd-example-apps.git&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Remember how I said earlier there are two ways we can get things done? You can definitely use one or the other (or both!) according to personal preference. I am a big fan of using the UI when first learning something in order to get a better idea of things I can do. So let’s start there to create our app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating Apps Via UI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Open a browser to the Argo CD external UI by visiting &lt;code&gt;localhost:8080&lt;/code&gt;, and login using the admin credentials we set up earlier. Your login page should look similar to this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/1fQTjR8fE34qOCCL4E6XPiYQWcJwm1NAs-QcEN_BpCM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzEucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/1fQTjR8fE34qOCCL4E6XPiYQWcJwm1NAs-QcEN_BpCM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzEucG5n" alt="https://codefresh.io/wp-content/uploads/2022/02/Argo1.png" width="640" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After logging in, click the “+ New App” button as shown below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/0SIJGAkw2sXKOGsTtmw8wgAH0zZ1gcPQlyWfmpRpB74/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzIucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/0SIJGAkw2sXKOGsTtmw8wgAH0zZ1gcPQlyWfmpRpB74/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzIucG5n" alt="https://codefresh.io/wp-content/uploads/2022/02/Argo2.png" width="305" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Give your app the name &lt;code&gt;guestbook&lt;/code&gt;, use the project &lt;code&gt;default&lt;/code&gt;, and leave the sync policy as &lt;code&gt;Manual&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/UyxPOIZdVQ_JbF6937NK-RPB0SvngLXFI-hEDhhPS-c/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzMucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/UyxPOIZdVQ_JbF6937NK-RPB0SvngLXFI-hEDhhPS-c/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzMucG5n" alt="https://codefresh.io/wp-content/uploads/2022/02/Argo3.png" width="441" height="473"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Connect the &lt;a href="https://github.com/argoproj/argocd-example-apps.git"&gt;https://github.com/argoproj/argocd-example-apps.git&lt;/a&gt; repo to Argo CD by setting repository URL to the GitHub repo URL, leave revision as &lt;code&gt;HEAD&lt;/code&gt;, and set the path to &lt;code&gt;guestbook&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/v1MUw-jv6iLptRB7fBZBVvIihpZOp1TCLxjC1ma3IkI/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzQucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/v1MUw-jv6iLptRB7fBZBVvIihpZOp1TCLxjC1ma3IkI/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzQucG5n" alt="https://codefresh.io/wp-content/uploads/2022/02/Argo4.png" width="418" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For &lt;strong&gt;Destination&lt;/strong&gt;, set cluster to &lt;code&gt;in-cluster&lt;/code&gt; and namespace to &lt;code&gt;default&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/7dF5Oiis7iEjljNxTUy5Hz7tcfbg8zx0BI3P72J23Lw/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzUucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/7dF5Oiis7iEjljNxTUy5Hz7tcfbg8zx0BI3P72J23Lw/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzUucG5n" alt="https://codefresh.io/wp-content/uploads/2022/02/Argo5.png" width="263" height="302"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We use &lt;code&gt;in-cluster&lt;/code&gt; because when deploying internally (i.e. to the same cluster that Argo CD is running in), the &lt;code&gt;https://kubernetes.default.svc&lt;/code&gt; hostname should be used as the application's Kubernetes API server address.&lt;/p&gt;

&lt;p&gt;After filling out the information above, click &lt;strong&gt;Create&lt;/strong&gt; at the top of the UI to create the guestbook application:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/LSydddtm5YCTAhFuI53UjncF91rSZZFxvGuExhOQmZA/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzYucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/LSydddtm5YCTAhFuI53UjncF91rSZZFxvGuExhOQmZA/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzYucG5n" alt="https://codefresh.io/wp-content/uploads/2022/02/Argo6.png" width="196" height="44"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating Apps Via CLI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To create that same app using the CLI, you would use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;argocd app create guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path guestbook --dest-server https://kubernetes.default.svc --dest-namespace default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When I do use the CLI, I still like to double-check myself using the UI occasionally. Do whichever is comfortable for you!&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Sync (Deploy) The Application
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Syncing via UI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once the guestbook application is created, you can now view its status:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/WAWDRo8jXq3modVLBEwBBOB5O0fmhTTw3ZxzUj5krXE/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzcucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/WAWDRo8jXq3modVLBEwBBOB5O0fmhTTw3ZxzUj5krXE/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzcucG5n" alt="https://codefresh.io/wp-content/uploads/2022/02/Argo7.png" width="650" height="466"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, the application status is &lt;code&gt;OutOfSync&lt;/code&gt;! &lt;code&gt;OutOfSync&lt;/code&gt; means the git state is different from the cluster state. You can see this information in multiple ways while in the UI. When the state is not in sync, you can usually tell as it is in a helpful yellow color. You can also filter by status on the left side of the dashboard. I highly recommend poking around the dashboard to see which configuration works for you!&lt;/p&gt;

&lt;p&gt;That said, the application status is initially in &lt;code&gt;OutOfSync&lt;/code&gt; state since the application has yet to be deployed. Also, no Kubernetes resources have been created. To sync (deploy) the application, we’ll use the “Sync” button.&lt;/p&gt;

&lt;p&gt;This will bring up a second set of options. Select “Synchronize”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/UIIlIxirxi_GKgeyJrCbs2bUKYFvs8a51uth6dVxJ0c/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzgucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/UIIlIxirxi_GKgeyJrCbs2bUKYFvs8a51uth6dVxJ0c/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzgucG5n" alt="https://codefresh.io/wp-content/uploads/2022/02/Argo8.png" width="602" height="598"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Synchronizing is how we deploy the application. When we “Sync” or “Synchronize”, it means we are updating the cluster state to match the Git state. This is one of the most important tenets of GitOps.&lt;/p&gt;

&lt;p&gt;Once things are complete and you return to the dashboard, you will see the guestbook app is now running. Select the app and see what information you can find!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/J6nk2k4iuxU-7bC0dBE4ViNzi_A0cDXG7IDBkbK0zKo/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzkucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/J6nk2k4iuxU-7bC0dBE4ViNzi_A0cDXG7IDBkbK0zKo/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzkucG5n" alt="https://codefresh.io/wp-content/uploads/2022/02/Argo9.png" width="807" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/5OTnVQUXxlffRLrNxdvTDFgq07BMu9Jk4V66A8fWUmM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzEwLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/5OTnVQUXxlffRLrNxdvTDFgq07BMu9Jk4V66A8fWUmM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzEwLnBuZw" alt="https://codefresh.io/wp-content/uploads/2022/02/Argo10.png" width="880" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you click on the application name, you will see a hierarchical view of all the Kubernetes resources that take part in the application. You will also see additional details related to the health and synchronization status.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syncing via CLI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Of course, everything we have done via the UI, can be done via CLI. Since we created the guestbook application, you can now check the status of your application using &lt;code&gt;argocd app get&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;argocd app get guestbook
&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;Name:               guestbook
Project:            default
Server:             https://kubernetes.default.svc
Namespace:          default
URL:                https://localhost:8080/applications/guestbook
Repo:               https://github.com/howmybrainworks/argocd-example-apps.git
Target:
Path:               guestbook
SyncWindow:         Sync Allowed
Sync Policy:        &amp;lt;none&amp;gt;
Sync Status:        OutOfSync from  (13b08f1)
Health Status:      Missing

GROUP  KIND        NAMESPACE  NAME          STATUS     HEALTH   HOOK  MESSAGE
       Service     default    guestbook-ui  OutOfSync  Missing
apps   Deployment  default    guestbook-ui  OutOfSync  Missing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you look at the “Sync Status” you will see the application status is initially in &lt;code&gt;OutOfSync&lt;/code&gt; state since the application has yet to be deployed, and no Kubernetes resources have been created. To sync (deploy) the application, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;argocd app sync guestbook
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Modifying and redeploying the Application&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Here is where I feel Argo CD really shines. Now that we have a healthy system, let's initiate a change. Let’s scale the deployment by modifying the replicas in the &lt;code&gt;deployment.yaml&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;deployment.yaml&lt;/code&gt; file, increase the number of replicas from 1 to 2. Since we are following &lt;a href="https://codefresh.io/gitops/"&gt;GitOps&lt;/a&gt;, we want our modification to be declarative. So, we are going to commit and submit this change via Git. This will show things &lt;code&gt;OutOfSync&lt;/code&gt; as well as identify configuration drift.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resyncing (redeploying) via UI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you go back to the UI, you should now see that we are now once again &lt;code&gt;OutOfSync&lt;/code&gt;!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/ZyZIBe9VEAFOzYQCBr-RF8kHKTw3C_PRWugz0ZHmDOI/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzExLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/ZyZIBe9VEAFOzYQCBr-RF8kHKTw3C_PRWugz0ZHmDOI/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzExLnBuZw" alt="https://codefresh.io/wp-content/uploads/2022/02/Argo11.png" width="631" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I sincerely love this feature, because not only does Argo CD let us know the application is no longer in sync, it also gives you a nice “App Diff” view to give more detail about what was changed! Click on the application name again, and you will see this option at the top of the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/EvJjg9dbb678jM-8aSxv40RllFrJXqWEGzVMsKlmEZY/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzEyLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/EvJjg9dbb678jM-8aSxv40RllFrJXqWEGzVMsKlmEZY/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzEyLnBuZw" alt="https://codefresh.io/wp-content/uploads/2022/02/Argo12.png" width="466" height="163"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, the default “Diff” view can potentially contain an enormous amount of information, so I like to select the “Compact Diff” option in order to immediately see any changes. As you can see, we increased our replicas from 1 &amp;gt; 2.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/YS-aGgq8us8J-ADY4XSwCqKN6oGiYtleJhqNEEwcrd4/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzEzLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/YS-aGgq8us8J-ADY4XSwCqKN6oGiYtleJhqNEEwcrd4/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzEzLnBuZw" alt="https://codefresh.io/wp-content/uploads/2022/02/Argo13.png" width="880" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow the same steps to deploy an application by using the “Sync” button, and we should be back to a healthy app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/ReTSBUl4tLk9k9dRLaDI9zF4xJArIs33JQv2EqYFT0w/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzE0LnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/ReTSBUl4tLk9k9dRLaDI9zF4xJArIs33JQv2EqYFT0w/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb2Rl/ZnJlc2guaW8vd3At/Y29udGVudC91cGxv/YWRzLzIwMjIvMDIv/QXJnbzE0LnBuZw" alt="https://codefresh.io/wp-content/uploads/2022/02/Argo14.png" width="647" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resyncing (redeploying) via CLI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's initiate another change. Let’s scale the deployment by modifying the number of replicas using &lt;code&gt;kubectl&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Using &lt;code&gt;kubectl&lt;/code&gt;, decrease the number of replicas from 2 to 1. You’ll do this using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl scale --current-replicas=2 --replicas=1 deployment/guestbook-ui
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Follow the same steps as above to retrieve our application status using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;argocd app get guestbook
&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;Name:               guestbook
Project:            default
Server:             https://kubernetes.default.svc
Namespace:          default
URL:                https://localhost:8080/applications/guestbook
Repo:               https://github.com/howmybrainworks/argocd-example-apps.git
Target:
Path:               guestbook
SyncWindow:         Sync Allowed
Sync Policy:        &amp;lt;none&amp;gt;
Sync Status:        OutOfSync from  (13b08f1)
Health Status:      Healthy

GROUP  KIND        NAMESPACE  NAME          STATUS     HEALTH   HOOK  MESSAGE
       Service     default    guestbook-ui  Synced     Healthy        service/guestbook-ui created
apps   Deployment  default    guestbook-ui  OutOfSync  Healthy        deployment.apps/guestbook-ui created
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you check your output, you will again see we are &lt;code&gt;OutOfSync&lt;/code&gt;. In order to see what’s changed, you’ll  use &lt;code&gt;argocd app diff&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;argocd app diff guestbook
&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;===== apps/Deployment default/guestbook-ui ======
109c109
&amp;lt;   replicas: 1
--
&amp;gt;   replicas: 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the sync command once again to deploy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;argocd app sync guestbook
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything should be back healthy and in order!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;As you can see, adopting GitOps is beneficial in many ways! Among other things, you gain faster and more frequent deployments, the ability to avoid configuration drift, and easier error handling. This is shown especially when coupled with Argo CD as it can help leverage your deployment process by performing commits automatically and can also execute rollbacks if there are any issues.&lt;/p&gt;

&lt;p&gt;Argo CD is great by itself, but it is even better when connected to other &lt;a href="https://argoproj.github.io/"&gt;Argo projects&lt;/a&gt; such as Argo Workflows, Rollouts, or Events. Combined with any of these, you can elevate your continuous deployment process.&lt;/p&gt;

</description>
      <category>tutorials</category>
      <category>devops</category>
      <category>gitops</category>
      <category>cicd</category>
    </item>
  </channel>
</rss>
