Simple example using Git actions + Argo CD + K8S + Docker and GO lang

CICD-simple_example

Simple example using Git actions + Argo CD + K8S + Docker and GO lang

Intro

Pre reqs

  • Have an ArgoCD account and Installed.
  • Docker installed.
  • Have k3D intalled.
  • Kubectl installed.
  • Have a Github account.
  • Unlimited of curiosity to learn new things.

Steps

  1. Create a K8S cluster k3d cluster create {clustername} (It is in your preference host, in this case are local with K3D).
  2. To list all contexts kubectl config get-contexts.
  3. Enter in K8S cluster's context kubectl cluster-info --context {clustername}.
  4. See if nodes are ok in cluster with kubectl get nodes.
  5. Create a app that you need, in this case a simple webserver in go.
  6. Make a Dockerfile using multistage build.
  7. Build image and send to registry if is necessary (in this case I will maintain local) docker build -t {myname}/{imagename}:{tag} ..
  8. Run image with command docker run --rm -p 9090:9090.
  9. Insert in line 16 of file k8s/deployment.yamlyour image address and in line 22 the port of application.
  10. To run deployment in your kubernetes cluster use the command: kubectl apply -f k8s/deployment.yaml.
  11. To see if deployment is running use kubectl get pods.
  12. To delete cluster k3d cluster delete {clustername}.

About Dockerfile

Explain about dockerfile for generating go image

# Multistage build
# First image compile a binary in GO

FROM golang:1.17 as build 
WORKDIR /app
COPY . . 
RUN CGO_ENABLED=0 go build -o server main.go

# Second image catch a binary from first and generate a simple and light image to use in webserver

FROM alpine:3.12
WORKDIR /app
COPY --from=build /app/server .
CMD ["./server"]

Reference

Materials used to reference:

Deploy contínuo com GitOps e ArgoCD k3d Docs ArgoCD ArgoCD Get Started

Owner
Diogo Miyake
Data Engineer with DevOps - DevSecOps - DataOps Machine Learning knowledge.
Diogo Miyake
Similar Resources

K8s-go-structs - All k8s API Go structs

k8s-api go types Why? Its nice to have it all in a single package. . |-- pkg |

Jul 17, 2022

Example goreleaser + github actions config with keyless signing and SBOM generation

supply-chain-example GoReleaser + Go Mod proxying + Cosign keyless signing + Syft SBOM generation example. How it works GoReleaser manages the entire

Nov 15, 2022

The example shows how to build a simple multi-tier web application using Kubernetes and Docker

The example shows how to build a simple multi-tier web application using Kubernetes and Docker

Guestbook Example This example shows how to build a simple multi-tier web application using Kubernetes and Docker. The application consists of a web f

Nov 15, 2021

Automating Kubernetes Rollouts with Argo and Prometheus. Checkout the demo URL below

Automating Kubernetes Rollouts with Argo and Prometheus. Checkout the demo URL below

observe-argo-rollout Demo for Automating and Monitoring Kubernetes Rollouts with Argo and Prometheus Performing Demo The demo can be found on Katacoda

Nov 16, 2022

A plugin for argo which behaves like I'd like

argocd-lovely-plugin An ArgoCD plugin to perform various manipulations in a sensible order to ultimately output YAML for Argo CD to put into your clus

Dec 27, 2022

The CLI tool glueing Git, Docker, Helm and Kubernetes with any CI system to implement CI/CD and Giterminism

The CLI tool glueing Git, Docker, Helm and Kubernetes with any CI system to implement CI/CD and Giterminism

___ werf is an Open Source CLI tool written in Go, designed to simplify and speed up the delivery of applications. To use it, you need to describe the

Jan 4, 2023

k8s-client-go example

k8s-client-go example k8s version: 1.21.2 提供两种方式连接到 k8s server connect.Connect() connect.DefaultConnect(), connect from .kube/config, more simple conf

Oct 30, 2021

Leader election example leveraging the the k8s client.

k8s-leader-election Leader election example leveraging the leaderelection pkg from the k8s client. Usage Create a k3d cluster: make cluster Deploy the

Dec 21, 2021

Kubelet-bench - Example Go-based e2e benchmark for various Kubelet operations without spinning up whole K8s cluster

kubelet-bench An example of Go based e2e benchmark for various Kubelet operation

Mar 17, 2022
Provider-generic-workflows - A generic provider which uses argo workflows to define the backend actions.

provider-generic-workflows provider-generic-workflows is a generic provider which uses argo workflows for managing the external resource. This will re

Jan 1, 2022
Write controller-runtime based k8s controllers that read/write to git, not k8s

Git Backed Controller The basic idea is to write a k8s controller that runs against git and not k8s apiserver. So the controller is reading and writin

Dec 10, 2021
github-actions-merger is github actions that merges pull request with commit message including pull request labels.

github-actions-merger github-actions-merger is github actions that merges pull request with commit message including pull request labels. Usage Write

Dec 7, 2022
A simple Go app and GitHub workflow that shows how to use GitHub Actions to test, build and deploy a Go app to Docker Hub

go-pipeline-demo A repository containing a simple Go app and GitHub workflow that shows how to use GitHub Actions to test, build and deploy a Go app t

Nov 17, 2021
Pulumi-k8s-operator-example - OpenGitOps Compliant Pulumi Kubernetes Operator Example

Pulumi GitOps Example OpenGitOps Compliant Pulumi Kubernetes Operator Example Pr

May 6, 2022
Container actions using Golang Docker SDK

container-go Prototyping continuous integration for microservices using only Gol

Dec 28, 2021
Hassle-free minimal CI/CD for git repositories with docker or docker-compose projects.
Hassle-free minimal CI/CD for git repositories with docker or docker-compose projects.

GIT-PIPE Hassle-free minimal CI/CD for git repos for docker-based projects. Features: zero configuration for repos by default automatic encrypted back

Sep 23, 2022
Go-http-server-docker - Simple sample server using docker and go

go-http-server-docker Simple sample webserver using docker and go.

Jan 8, 2022
K8s-cinder-csi-plugin - K8s Pod Use Openstack Cinder Volume

k8s-cinder-csi-plugin K8s Pod Use Openstack Cinder Volume openstack volume list

Jul 18, 2022
K8s-ingress-health-bot - A K8s Ingress Health Bot is a lightweight application to check the health of the ingress endpoints for a given kubernetes namespace.

k8s-ingress-health-bot A K8s Ingress Health Bot is a lightweight application to check the health of qualified ingress endpoints for a given kubernetes

Jan 2, 2022