sommerfeld-io-archive / vm-ubuntu

Config and Setup for a Ubuntu Desktop VM which is not managed through Vagrant
https://sommerfeld-io.github.io/vm-ubuntu/
Other
0 stars 0 forks source link

Deploy ArgoCD into Minikube #13

Closed sebastian-sommerfeld-io closed 1 day ago

sebastian-sommerfeld-io commented 1 month ago

Relates to #18

Automate deployments so they react to changes automatically (through gitops). Scaling should be done automatically as well as updating a version. Move from helm to ArgoCD for this. Just deploy ArgoCD with helm as part of the admin-charts



sebastian-sommerfeld-io commented 4 weeks ago

To deploy a demo app like httpd:latest in your Minikube cluster using ArgoCD, you need to follow these steps:

1. Install ArgoCD on Minikube

First, ensure that ArgoCD is installed and running in your Minikube cluster.

kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

Wait for ArgoCD to start:

kubectl get pods -n argocd

2. Expose ArgoCD API Server

To access the ArgoCD UI, you need to expose the ArgoCD API server on Minikube.

kubectl port-forward svc/argocd-server -n argocd 8080:443

Access the ArgoCD UI at https://localhost:8080 and login with the default username admin. You can retrieve the initial password with:

kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath="{.data.password}" | base64 -d

3. Create a Git Repository for the App's Helm/Manifests

# httpd-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: httpd-deployment
  labels:
    app: httpd
spec:
  replicas: 1
  selector:
    matchLabels:
      app: httpd
  template:
    metadata:
      labels:
        app: httpd
    spec:
      containers:
      - name: httpd
        image: httpd:latest
        ports:
        - containerPort: 80

# httpd-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: httpd-service
spec:
  selector:
    app: httpd
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80

Push the files to a Git repository, such as GitHub or GitLab.

4. Create an ArgoCD Application

In the ArgoCD UI or using a CLI, create an ArgoCD Application that will monitor the Git repository containing your app manifests or Helm chart. Here's an example of creating it via a YAML file:

# argocd-app.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: httpd-app
  namespace: argocd
spec:
  destination:
    namespace: default
    server: https://kubernetes.default.svc
  source:
    repoURL: 'https://github.com/your-repo/httpd-demo'
    path: 'manifests'
    targetRevision: HEAD
  project: default
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

Apply this file to your ArgoCD namespace:

kubectl apply -f argocd-app.yaml -n argocd

5. Sync the Application in ArgoCD

In the ArgoCD UI, locate the httpd-app and sync it to deploy the httpd app to your Minikube cluster. You should see the application in the UI.

Alternatively, you can sync via CLI:

argocd app sync httpd-app

6. Access the Deployed App

To access the deployed httpd service, you need to expose it. You can either use port-forwarding or Minikube’s service URL:

minikube service httpd-service

This command will open the service in your default web browser.

Summary

This setup uses plain Kubernetes manifests, but you can also use Helm charts for more complex applications. Would you prefer a Helm-based setup instead?

sebastian-sommerfeld-io commented 4 weeks ago

ArgoCD Autopilot is an exciting tool that can significantly enhance your experience with ArgoCD, especially in managing and deploying Kubernetes applications. Here are some key aspects and benefits of using ArgoCD Autopilot:

1. Simplified Application Management

2. Opinionated Structure

3. Automatic Dependency Management

4. Integration with GitHub

5. Enhanced Monitoring and Health Checks

6. Rollbacks and History Management

7. Community and Ecosystem

Considerations

Conclusion

ArgoCD Autopilot is a powerful addition for teams looking to implement GitOps practices effectively. It can greatly reduce the operational burden of managing Kubernetes applications while ensuring consistency and best practices. If your team is adopting ArgoCD, leveraging Autopilot can enhance your workflow and help you get the most out of your GitOps implementation.

If you're considering using ArgoCD Autopilot, I'd be happy to help with the setup or any specific questions you might have!

sebastian-sommerfeld-io commented 4 weeks ago

To start using ArgoCD Autopilot in your Minikube setup, follow these steps:

1. Install ArgoCD Autopilot

First, ensure you have the ArgoCD Autopilot CLI installed. You can download the latest version from the ArgoCD Autopilot GitHub releases page.

For example, on a Unix-like system, you can install it using:

curl -sSL https://github.com/argoproj-labs/argocd-autopilot/releases/latest/download/argocd-autopilot-linux-amd64 -o argocd-autopilot
chmod +x argocd-autopilot
sudo mv argocd-autopilot /usr/local/bin/

2. Set Up Your Git Repository

Create a Git repository for your applications. This repository will store your application configurations managed by ArgoCD Autopilot. You might structure it like this:

your-git-repo/
├── apps/
│   └── httpd/
│       ├── app.yaml
│       └── ...
├── clusters/
│   └── minikube/
│       ├── app.yaml
│       └── ...
└── README.md

3. Initialize Autopilot in Your Repository

Navigate to your repository's root directory and initialize ArgoCD Autopilot:

cd your-git-repo
argocd-autopilot init

This command creates the necessary files and directories for managing your applications.

4. Create Your Application with Autopilot

Create a new application (e.g., for httpd) using Autopilot. Run the following command:

argocd-autopilot app create httpd \
  --repo your-git-repo-url \
  --path apps/httpd \
  --dest-namespace default \
  --dest-server https://kubernetes.default.svc

5. Add Your Application Configuration

Edit apps/httpd/app.yaml to define your httpd application. Here's a simple example for an HTTPD deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: httpd
  labels:
    app: httpd
spec:
  replicas: 1
  selector:
    matchLabels:
      app: httpd
  template:
    metadata:
      labels:
        app: httpd
    spec:
      containers:
      - name: httpd
        image: httpd:latest
        ports:
        - containerPort: 80

---
apiVersion: v1
kind: Service
metadata:
  name: httpd
spec:
  selector:
    app: httpd
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80

6. Deploy the Application

Once you have configured your application, commit and push your changes to your Git repository:

git add .
git commit -m "Add httpd application"
git push origin main

7. Register Your Git Repository with ArgoCD

You need to add your Git repository to ArgoCD so it can monitor your applications:

argocd repo add your-git-repo-url --username <username> --password <password>

8. Sync Your Application with ArgoCD

Now, you can create the application in ArgoCD using the following command:

argocd app create httpd \
  --repo your-git-repo-url \
  --path apps/httpd \
  --dest-namespace default \
  --dest-server https://kubernetes.default.svc

To sync the application, run:

argocd app sync httpd

9. Access the Application

To access the httpd service, you can use the Minikube service command:

minikube service httpd

This will open the service in your default web browser.

Summary

With these steps, you should be able to set up ArgoCD Autopilot in your Minikube environment effectively. If you have any specific configurations or adjustments in mind, let me know!

sebastian-sommerfeld-io commented 3 weeks ago

Chat GPT:

To set up a playground for ArgoCD with Minikube and keep the ArgoCD configuration in a repository containing Helm scripts and the ArgoCD config, here's how I would start:

1. Prepare the Minikube Environment

2. Create a Git Repository for ArgoCD Configurations

3. Install ArgoCD using Helm

4. Setup ArgoCD Configuration in the Repository

5. Bootstrap ArgoCD with GitOps

6. Automating ArgoCD Sync

7. Testing and Iterating

Now you can start experimenting with ArgoCD in your Minikube environment, managing deployments using the configuration stored in your Git repository.