From 61c38109ac977e87042a180956d2125d37e427dc Mon Sep 17 00:00:00 2001 From: sujata pachore Date: Sun, 19 Jul 2026 23:18:21 +0530 Subject: [PATCH 1/6] Implemented CI --- Dockerfile | 15 ++++ k8s/manifests/.github/workflows/ci.yaml | 82 ++++++++++++++++++ k8s/manifests/.service.yaml.un~ | Bin 0 -> 2291 bytes k8s/manifests/deployment.yaml | 22 +++++ .../helm/go-web-app-chart/.helmignore | 23 +++++ .../helm/go-web-app-chart/Chart.yaml | 24 +++++ .../templates/deployment.yaml | 22 +++++ .../go-web-app-chart/templates/ingress.yaml | 21 +++++ .../go-web-app-chart/templates/service.yaml | 15 ++++ .../helm/go-web-app-chart/values.yaml | 23 +++++ k8s/manifests/ingress.yaml | 21 +++++ k8s/manifests/service.yaml | 15 ++++ k8s/manifests/service.yaml~ | 15 ++++ 13 files changed, 298 insertions(+) create mode 100644 Dockerfile create mode 100644 k8s/manifests/.github/workflows/ci.yaml create mode 100644 k8s/manifests/.service.yaml.un~ create mode 100644 k8s/manifests/deployment.yaml create mode 100644 k8s/manifests/helm/go-web-app-chart/.helmignore create mode 100644 k8s/manifests/helm/go-web-app-chart/Chart.yaml create mode 100644 k8s/manifests/helm/go-web-app-chart/templates/deployment.yaml create mode 100644 k8s/manifests/helm/go-web-app-chart/templates/ingress.yaml create mode 100644 k8s/manifests/helm/go-web-app-chart/templates/service.yaml create mode 100644 k8s/manifests/helm/go-web-app-chart/values.yaml create mode 100644 k8s/manifests/ingress.yaml create mode 100644 k8s/manifests/service.yaml create mode 100644 k8s/manifests/service.yaml~ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..5d9bdeaed --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM golang:1.22 AS base +WORKDIR /app + +COPY go.mod . +RUN go mod download +COPY . . +RUN go build -o main . + +## Final stage with distroless image ## +FROM gcr.io/distroless/base:nonroot +WORKDIR /app +COPY --from=base /app/main . +COPY --from=base /app/static ./static +EXPOSE 8080 +CMD ["./main"] \ No newline at end of file diff --git a/k8s/manifests/.github/workflows/ci.yaml b/k8s/manifests/.github/workflows/ci.yaml new file mode 100644 index 000000000..ddc66de46 --- /dev/null +++ b/k8s/manifests/.github/workflows/ci.yaml @@ -0,0 +1,82 @@ +name: CI +on: + push: + branches: + - main + paths-ignore: + - 'README.md' + - 'helm/**' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Go 1.22 + uses: actions/setup-go@v4 + with: + go-version: 1.22 + + - name: Build + run: go build -o go-web-app + + - name: Test + run: go test ./... + + code-quality: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v4 + with: + version: v1.56.2 + + push: + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and Push action + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/go-web-app:${{ github.run_id }} + + update-newtag-in-helm-chart: + runs-on: ubuntu-latest + needs: push + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.TOKEN }} + + - name: Update tag in Helm chart + run: | + sed -i 's/tag: .*/tag: "${{ github.run_id }}"/' helm/go-web-app-chart/values.yaml + + - name: Commit and push changes + run: | + git config --global user.email "abhishek@gmail.com" + git config --global user.name "Abhishek Veeramalla" + git add helm/go-web-app-chart/values.yaml + git commit -m "Update tag in Helm chart" + git push \ No newline at end of file diff --git a/k8s/manifests/.service.yaml.un~ b/k8s/manifests/.service.yaml.un~ new file mode 100644 index 0000000000000000000000000000000000000000..05054d19bb0c616d8db14ea6001eb0d8ed26ba82 GIT binary patch literal 2291 zcmWH`%$*;a=aT=FfoYED&qrS;XB^nHmHVBEtlfhtHzpgb`jKp#`7L6LVjAZ+1_lOx zAQn_mD5)$+wNh}-DJ?EZE%FQi3UUB39}qJFF)I**0EmWRhOFrAJuDzuMuzwcAXy+_ zf>2-*Bn2~s;Xe?7jY3i|%A{rp0HdP`932b{UnPJBvjZ_F5Q8EZ6cw0}Y}yEpH;^PV z5W@f{4ngt80}>dGH&7_h5&+|^8DG5dA!SZr&V)u9D3Vx^oCS(NP^58z#6}|x6biHi zz({Mw7irw^NQ1{1D28C=D9CA`*aO8F2#>}XC=h50fHBsIFUB}wF$T+F$hiyTGEm%& d#urWF2-$F8e0784ixGQu#sQ5lV01lS1ppjwU{(MC literal 0 HcmV?d00001 diff --git a/k8s/manifests/deployment.yaml b/k8s/manifests/deployment.yaml new file mode 100644 index 000000000..5ccf320a7 --- /dev/null +++ b/k8s/manifests/deployment.yaml @@ -0,0 +1,22 @@ +apiVersion : apps/v1 +kind : Deployment +metadata: + name : go-web-app + labels: + app : go-web-app +spec: + replicas: 2 + selector: + matchLabels: + app: go-web-app + template: + metadata: + labels: + app: go-web-app + spec: + containers: + - name: go-web-app + image: c5375391/go-web-app:v5 + ports: + - containerPort: 8080 + diff --git a/k8s/manifests/helm/go-web-app-chart/.helmignore b/k8s/manifests/helm/go-web-app-chart/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/k8s/manifests/helm/go-web-app-chart/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/k8s/manifests/helm/go-web-app-chart/Chart.yaml b/k8s/manifests/helm/go-web-app-chart/Chart.yaml new file mode 100644 index 000000000..5d5e4a81b --- /dev/null +++ b/k8s/manifests/helm/go-web-app-chart/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: go-web-app-chart +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/k8s/manifests/helm/go-web-app-chart/templates/deployment.yaml b/k8s/manifests/helm/go-web-app-chart/templates/deployment.yaml new file mode 100644 index 000000000..54a10e6b1 --- /dev/null +++ b/k8s/manifests/helm/go-web-app-chart/templates/deployment.yaml @@ -0,0 +1,22 @@ +apiVersion : apps/v1 +kind : Deployment +metadata: + name : go-web-app + labels: + app : go-web-app +spec: + replicas: 2 + selector: + matchLabels: + app: go-web-app + template: + metadata: + labels: + app: go-web-app + spec: + containers: + - name: go-web-app + image: c5375391/go-web-app:{{ .Values.image.tag }} + ports: + - containerPort: 8080 + diff --git a/k8s/manifests/helm/go-web-app-chart/templates/ingress.yaml b/k8s/manifests/helm/go-web-app-chart/templates/ingress.yaml new file mode 100644 index 000000000..e77687f5a --- /dev/null +++ b/k8s/manifests/helm/go-web-app-chart/templates/ingress.yaml @@ -0,0 +1,21 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: go-web-app + labels: + app: go-web-app + annotations: + kubernetes.io/ingress.class: "nginx" +spec: + ingressClassName: nginx + rules: + - host: go-web-app.local + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: go-web-app + port: + number: 8080 diff --git a/k8s/manifests/helm/go-web-app-chart/templates/service.yaml b/k8s/manifests/helm/go-web-app-chart/templates/service.yaml new file mode 100644 index 000000000..3286d83b1 --- /dev/null +++ b/k8s/manifests/helm/go-web-app-chart/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: go-web-app + labels: + app: go-web-app +spec: + type: NodePort + selector: + app: go-web-app + ports: + - port: 8080 + targetPort: 8080 + + diff --git a/k8s/manifests/helm/go-web-app-chart/values.yaml b/k8s/manifests/helm/go-web-app-chart/values.yaml new file mode 100644 index 000000000..c9c43e35e --- /dev/null +++ b/k8s/manifests/helm/go-web-app-chart/values.yaml @@ -0,0 +1,23 @@ +# Default values for go-web-app-chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: c5375391/go-web-app + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "v5" + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific \ No newline at end of file diff --git a/k8s/manifests/ingress.yaml b/k8s/manifests/ingress.yaml new file mode 100644 index 000000000..e77687f5a --- /dev/null +++ b/k8s/manifests/ingress.yaml @@ -0,0 +1,21 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: go-web-app + labels: + app: go-web-app + annotations: + kubernetes.io/ingress.class: "nginx" +spec: + ingressClassName: nginx + rules: + - host: go-web-app.local + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: go-web-app + port: + number: 8080 diff --git a/k8s/manifests/service.yaml b/k8s/manifests/service.yaml new file mode 100644 index 000000000..3286d83b1 --- /dev/null +++ b/k8s/manifests/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: go-web-app + labels: + app: go-web-app +spec: + type: NodePort + selector: + app: go-web-app + ports: + - port: 8080 + targetPort: 8080 + + diff --git a/k8s/manifests/service.yaml~ b/k8s/manifests/service.yaml~ new file mode 100644 index 000000000..d5032d63e --- /dev/null +++ b/k8s/manifests/service.yaml~ @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: go-web-app + labels: + app: go-web-app +spec: + type: ClusterIP + selector: + app: go-web-app + ports: + - port: 8080 + targetPort: 8080 + + \ No newline at end of file From 7eae7da6ba4881d89b45f8a491ffc3345c01d8fe Mon Sep 17 00:00:00 2001 From: Sujata0709 Date: Sun, 19 Jul 2026 23:52:29 +0530 Subject: [PATCH 2/6] Create ci.yaml --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1 @@ + From 72fd1ee1fff38f2ab32d649b24e9e8cf56e9173c Mon Sep 17 00:00:00 2001 From: sujata pachore Date: Mon, 20 Jul 2026 00:07:45 +0530 Subject: [PATCH 3/6] new changes --- k8s/manifests/.github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k8s/manifests/.github/workflows/ci.yaml b/k8s/manifests/.github/workflows/ci.yaml index ddc66de46..2610d28cd 100644 --- a/k8s/manifests/.github/workflows/ci.yaml +++ b/k8s/manifests/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: CI +name: CI on: push: branches: @@ -55,7 +55,7 @@ jobs: - name: Build and Push action uses: docker/build-push-action@v6 with: - context: . + context: file: ./Dockerfile push: true tags: ${{ secrets.DOCKERHUB_USERNAME }}/go-web-app:${{ github.run_id }} From de3a48d4ab4d5286b0dfd0be9e7fb2d5fd099cd2 Mon Sep 17 00:00:00 2001 From: sujata pachore Date: Mon, 20 Jul 2026 00:10:53 +0530 Subject: [PATCH 4/6] new changesv2 --- k8s/manifests/.github/workflows/ci.yaml | 123 +++++++++++++----------- 1 file changed, 68 insertions(+), 55 deletions(-) diff --git a/k8s/manifests/.github/workflows/ci.yaml b/k8s/manifests/.github/workflows/ci.yaml index 2610d28cd..6a879092d 100644 --- a/k8s/manifests/.github/workflows/ci.yaml +++ b/k8s/manifests/.github/workflows/ci.yaml @@ -1,82 +1,95 @@ -name: CI +# CICD using GitHub actions + +name: CI/CD + +# Exclude the workflow to run on changes to the helm chart on: push: branches: - main paths-ignore: - - 'README.md' - 'helm/**' + - 'k8s/**' + - 'README.md' jobs: + build: runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - name: Set up Go 1.22 - uses: actions/setup-go@v4 - with: - go-version: 1.22 + steps: + - name: Checkout repository + uses: actions/checkout@v4 - - name: Build - run: go build -o go-web-app + - name: Set up Go 1.22 + uses: actions/setup-go@v2 + with: + go-version: 1.22 - - name: Test - run: go test ./... + - name: Build + run: go build -o go-web-app + - name: Test + run: go test ./... + code-quality: runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - name: Run golangci-lint - uses: golangci/golangci-lint-action@v4 - with: - version: v1.56.2 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.56.2 + push: runs-on: ubuntu-latest + needs: build + steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and Push action - uses: docker/build-push-action@v6 - with: - context: - file: ./Dockerfile - push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/go-web-app:${{ github.run_id }} + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and Push action + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/go-web-app:${{github.run_id}} update-newtag-in-helm-chart: runs-on: ubuntu-latest + needs: push + steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - token: ${{ secrets.TOKEN }} - - - name: Update tag in Helm chart - run: | - sed -i 's/tag: .*/tag: "${{ github.run_id }}"/' helm/go-web-app-chart/values.yaml - - - name: Commit and push changes - run: | - git config --global user.email "abhishek@gmail.com" - git config --global user.name "Abhishek Veeramalla" - git add helm/go-web-app-chart/values.yaml - git commit -m "Update tag in Helm chart" - git push \ No newline at end of file + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.TOKEN }} + + - name: Update tag in Helm chart + run: | + sed -i 's/tag: .*/tag: "${{github.run_id}}"/' helm/go-web-app-chart/values.yaml + + - name: Commit and push changes + run: | + git config --global user.email "abhishek@gmail.com" + git config --global user.name "Abhishek Veeramalla" + git add helm/go-web-app-chart/values.yaml + git commit -m "Update tag in Helm chart" + git push + From 486f05cc49cfc42202a942b7d0fac42a54cbdbab Mon Sep 17 00:00:00 2001 From: sujata pachore Date: Mon, 20 Jul 2026 00:15:33 +0530 Subject: [PATCH 5/6] new changesv3 --- k8s/manifests/.github/workflows/ci.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/k8s/manifests/.github/workflows/ci.yaml b/k8s/manifests/.github/workflows/ci.yaml index 6a879092d..ced553703 100644 --- a/k8s/manifests/.github/workflows/ci.yaml +++ b/k8s/manifests/.github/workflows/ci.yaml @@ -7,11 +7,7 @@ on: push: branches: - main - paths-ignore: - - 'helm/**' - - 'k8s/**' - - 'README.md' - + jobs: build: From 9f0150ad18486b187156f5100d11701b0f9c0db4 Mon Sep 17 00:00:00 2001 From: sujata pachore Date: Mon, 20 Jul 2026 00:24:23 +0530 Subject: [PATCH 6/6] new changesv3 --- k8s/manifests/.github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/manifests/.github/workflows/ci.yaml b/k8s/manifests/.github/workflows/ci.yaml index ced553703..8dcff8fcc 100644 --- a/k8s/manifests/.github/workflows/ci.yaml +++ b/k8s/manifests/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Go 1.22 - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: go-version: 1.22