Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging #3

Open
wants to merge 133 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
9140caa
all
akatruk Jan 22, 2024
4a78ae8
h
akatruk Jan 22, 2024
c3d2eef
lint version
akatruk Jan 22, 2024
57328c8
d
akatruk Jan 22, 2024
1abce07
rm test
akatruk Jan 22, 2024
930f287
fff
akatruk Jan 22, 2024
a8bfee3
g
akatruk Jan 22, 2024
0f5dad9
f
akatruk Jan 22, 2024
9afd2e2
fix actions
akatruk Jan 22, 2024
87618f1
f
akatruk Jan 22, 2024
5c9a1ee
f
akatruk Jan 22, 2024
30d8f45
g
akatruk Jan 22, 2024
73351eb
f
akatruk Jan 22, 2024
01f4f0c
f
akatruk Jan 22, 2024
c0af3e8
full build
akatruk Jan 22, 2024
8087f35
fffffff
akatruk Jan 22, 2024
eaad921
d
akatruk Jan 22, 2024
5c24788
k
akatruk Jan 22, 2024
eee61a2
r
akatruk Jan 22, 2024
4a06b72
added
akatruk Jan 23, 2024
5bc7e31
f
akatruk Jan 23, 2024
4e762ca
f
akatruk Jan 23, 2024
6b6a244
f
akatruk Jan 23, 2024
8f2f996
f
akatruk Jan 23, 2024
31ad351
f
akatruk Jan 23, 2024
350aa8e
f
akatruk Jan 23, 2024
87ff193
k
akatruk Jan 23, 2024
4223474
k
akatruk Jan 23, 2024
2b820a3
fff
akatruk Jan 23, 2024
bdc0e76
d
akatruk Jan 23, 2024
1bd5279
f
akatruk Jan 23, 2024
e2d16e4
stg
akatruk Jan 23, 2024
b31dca9
fff
akatruk Jan 23, 2024
4fe5de4
fff
akatruk Jan 23, 2024
742f12a
fix
akatruk Jan 23, 2024
ee26906
f
akatruk Jan 23, 2024
eb935d2
f
akatruk Jan 23, 2024
e3af776
fff
akatruk Jan 23, 2024
c37760e
fffg
akatruk Jan 23, 2024
dd4c61d
ff
akatruk Jan 23, 2024
cd85cdd
stg
akatruk Jan 23, 2024
001d684
stg1
akatruk Jan 23, 2024
f06b7bd
f
akatruk Jan 23, 2024
093c8a2
f
akatruk Jan 23, 2024
4bcfe8f
f
akatruk Jan 23, 2024
c6f8bc1
f
akatruk Jan 23, 2024
0629a79
fff
akatruk Jan 23, 2024
a73f6d8
Merge branch 'master' into staging
akatruk Jan 23, 2024
df618df
fix main.go
akatruk Jan 23, 2024
e437ecb
Merge pull request #1 from akatruk/staging
akatruk Jan 23, 2024
4aacf27
f
akatruk Jan 23, 2024
62216fc
dd
akatruk Jan 23, 2024
12aa983
x
akatruk Jan 23, 2024
b1e77f0
d
akatruk Jan 23, 2024
b9f0432
fe1
akatruk Jan 23, 2024
f239356
fix version
akatruk Jan 23, 2024
dcc0a19
fix on master
akatruk Jan 23, 2024
e17a2aa
fix apply
akatruk Jan 23, 2024
ca0c518
fe
akatruk Jan 23, 2024
4f85b0a
www
akatruk Jan 23, 2024
c2c8894
${{ github.sha }}
akatruk Jan 24, 2024
f5dfd3b
sha_short
akatruk Jan 24, 2024
021ffda
fix1
akatruk Jan 24, 2024
3f982df
fix last
akatruk Jan 24, 2024
2947253
fff3
akatruk Jan 24, 2024
4ca781c
f
akatruk Jan 24, 2024
5aea151
f
akatruk Jan 24, 2024
372aa60
f
akatruk Jan 24, 2024
bf021a8
f
akatruk Jan 24, 2024
b06f5d6
rrr
akatruk Jan 24, 2024
0c47170
ffff
akatruk Jan 24, 2024
fa4725a
ffffffff1
akatruk Jan 24, 2024
e868cf8
ffff
akatruk Jan 24, 2024
2299e06
fffff
akatruk Jan 24, 2024
f683806
update argocd
akatruk Jan 24, 2024
1c49175
пппппп
akatruk Jan 24, 2024
3202ae3
gggg
akatruk Jan 24, 2024
35a8d68
fff
akatruk Jan 24, 2024
e1e7d10
fff
akatruk Jan 24, 2024
0834c1b
ffff
akatruk Jan 24, 2024
aadf642
ffff
akatruk Jan 24, 2024
6578295
f
akatruk Jan 24, 2024
1145e34
аааа
akatruk Jan 24, 2024
adfcc73
fix docker 1
akatruk Jan 24, 2024
6fe8703
ddd
akatruk Jan 25, 2024
b87b000
f
akatruk Jan 25, 2024
a939b4e
f
akatruk Jan 25, 2024
97be588
f
akatruk Jan 25, 2024
cf423f4
gg
akatruk Jan 25, 2024
09da7f5
f
akatruk Jan 25, 2024
79d5bcd
fix1
akatruk Jan 25, 2024
c5303bd
f
akatruk Jan 25, 2024
7a3be7e
fix2
akatruk Jan 25, 2024
0c2fa98
f
akatruk Jan 25, 2024
ca794b3
f
akatruk Jan 25, 2024
2ba3073
fix3
akatruk Jan 25, 2024
6550899
fix4
akatruk Jan 25, 2024
6bd82e4
fix5
akatruk Jan 25, 2024
856f01f
fff
akatruk Jan 25, 2024
3824c6d
change install
akatruk Jan 25, 2024
f8df23e
fix wget
akatruk Jan 25, 2024
1e60416
fix wget link
akatruk Jan 25, 2024
3b4bdfb
check var
akatruk Jan 25, 2024
ab64d0a
yq_linux_amd64
akatruk Jan 25, 2024
5f37fe1
check ls & pwd
akatruk Jan 25, 2024
9daeec0
а
akatruk Jan 25, 2024
74b3448
4.14.1
akatruk Jan 25, 2024
edb4cf2
check1
akatruk Jan 25, 2024
d02a453
test ${{ steps.var.outputs.DOCKER_TAG }}
akatruk Jan 25, 2024
2160f15
${{ steps.var.outputs.DOCKER_TAG }}
akatruk Jan 25, 2024
7cee4fe
${{ steps.var.outputs.DOCKER_TAG }} v2
akatruk Jan 25, 2024
6a54d76
echo "::set-output name=DOCKER_TAG::$DOCKER_TAG" v3
akatruk Jan 25, 2024
58c6cb0
new var
akatruk Jan 25, 2024
4daf16e
echo "::set-output name=DOCKER_TAG::$DOCKER_TAG"
akatruk Jan 25, 2024
3b97376
echo "::set-output name=DOCKER_TAG::$DOCKER_TAG"
akatruk Jan 25, 2024
31a1005
g
akatruk Jan 25, 2024
6fa2f29
apply new
akatruk Jan 25, 2024
408a41b
tag: v0.0.2
akatruk Jan 25, 2024
a98afc3
added annotation
akatruk Jan 25, 2024
445da6d
hhh
akatruk Jan 25, 2024
451ff64
v0.0.3
akatruk Jan 25, 2024
d9772ff
check
akatruk Jan 25, 2024
cfe8518
test dockerfile FROM 1
akatruk Jan 25, 2024
b0621f8
1.22rc2-alpine3.19
akatruk Jan 25, 2024
ce7cc70
alpine
akatruk Jan 25, 2024
71d9475
COPY --from=build /app/main .
akatruk Jan 25, 2024
7732265
CMD ["sleep", "10000"]
akatruk Jan 25, 2024
f8b422a
tag: alpine-test-1
akatruk Jan 25, 2024
fff11d3
tag: v0.0.1
akatruk Jan 26, 2024
66902f7
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-…
akatruk Jan 26, 2024
9ea2441
v0.0.2
akatruk Jan 26, 2024
a63c4b2
test stg
Andrei-Katruk Jan 29, 2024
6962986
fix
Andrei-Katruk Jan 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/cd-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI/CD Pipeline on master branch

on:
push:
branches:
- master

jobs:
build-and-push-production:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Docker
uses: docker/[email protected]

- name: Install yq
run: |
wget https://github.com/mikefarah/yq/releases/download/v4.14.1/yq_linux_amd64 -O yq
chmod +x yq
sudo mv yq /usr/local/bin/

- name: Extract Variables from values.yaml
id: var
run: |
export DOCKER_TAG=$(yq eval 'tojson' devops/values-prod.yml | jq '.app.containers.tag')
echo "::set-output name=DOCKER_TAG::$DOCKER_TAG"

- name: Build Docker image
id: build
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker build -t ghcr.io/${{ github.repository_owner }}/p2p-devops-test:${{ steps.var.outputs.DOCKER_TAG }} -f devops/.docker/dockerfile .
docker push ghcr.io/${{ github.repository_owner }}/p2p-devops-test:${{ steps.var.outputs.DOCKER_TAG }}

- name: Set up kubectl
uses: azure/setup-kubectl@v1
with:
version: 'latest'

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Generate kubectl config
run: |
aws eks update-kubeconfig --name eks-prod --region us-east-1

- name: Apply ArgoCD Manifests
run: |
kubectl apply -f devops/argocd/argocd-prod.yml --validate=false
37 changes: 37 additions & 0 deletions .github/workflows/cd-stg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI/CD Pipeline on master branch

on:
push:
branches:
- staging

jobs:
build-and-push-staging:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Docker
uses: docker/[email protected]

- name: Install yq
run: |
wget https://github.com/mikefarah/yq/releases/download/v4.14.1/yq_linux_amd64 -O yq
chmod +x yq
sudo mv yq /usr/local/bin/

- name: Extract Variables from values.yaml
id: var
run: |
export DOCKER_TAG=$(yq eval 'tojson' devops/values-stg.yml | jq '.app.containers.tag')
echo "::set-output name=DOCKER_TAG::$DOCKER_TAG"

- name: Build Docker image
id: build
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker build -t ghcr.io/${{ github.repository_owner }}/p2p-devops-test:${{ steps.var.outputs.DOCKER_TAG }} -f devops/.docker/dockerfile .
docker push ghcr.io/${{ github.repository_owner }}/p2p-devops-test:${{ steps.var.outputs.DOCKER_TAG }}

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@




if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref == 'refs/heads/master'


kubectl apply -f devops/argocd-prod.yml --validate=false
6 changes: 6 additions & 0 deletions devops/.docker/backup
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM golang:1.21 as build
WORKDIR /app
ADD ../../../ .
RUN go build main.go
EXPOSE 3000
CMD ["./main"]
10 changes: 10 additions & 0 deletions devops/.docker/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM golang:1.21 as build
WORKDIR /app
ADD ../../../ .
RUN go build main.go
FROM golang:alpine
WORKDIR /app
COPY --from=build /app/main .
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
EXPOSE 3000
CMD ["./main"]
4 changes: 4 additions & 0 deletions devops/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: p2p-devops-test
description: A Helm chart for deploying a Golang application with HPA, Deployment, and Service
version: 0.1.0
29 changes: 29 additions & 0 deletions devops/argocd/argocd-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
annotations:
argocd-image-updater.argoproj.io/image-alias.allow-tags: 'regexp:^1.3.0-SNAPSHOT.[0-9]+$'
argocd-image-updater.argoproj.io/image-alias.force-update: 'true'
argocd-image-updater.argoproj.io/image-alias.update-strategy: latest
finalizers:
- resources-finalizer.argocd.argoproj.io
name: p2p-devops-test-production
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/akatruk/p2p-devops-test
path: devops
targetRevision: master
helm:
valueFiles:
- values-prod.yml
destination:
server: https://kubernetes.default.svc
namespace: p2p-devops-test-production

syncPolicy:
automated:
prune: true
selfHeal: true
30 changes: 30 additions & 0 deletions devops/argocd/argocd-stg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
annotations:
argocd-image-updater.argoproj.io/image-alias.allow-tags: 'regexp:^1.3.0-SNAPSHOT.[0-9]+$'
argocd-image-updater.argoproj.io/image-alias.force-update: 'true'
argocd-image-updater.argoproj.io/image-alias.update-strategy: latest
name: p2p-devops-test-staging
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/akatruk/p2p-devops-test
path: devops
targetRevision: staging
helm:
valueFiles:
- values-stg.yml
destination:
server: https://kubernetes.default.svc
namespace: p2p-devops-test-staging

syncPolicy:
syncOptions:
- CreateNamespace=true

automated:
prune: true
selfHeal: true

4 changes: 4 additions & 0 deletions devops/templates/00-preinstall.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: {{ .Values.app.namespace }}
35 changes: 35 additions & 0 deletions devops/templates/01-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.app.name }}
namespace: {{ .Values.app.namespace }}
spec:
replicas: {{ .Values.app.replicas }}
selector:
matchLabels:
app: {{ .Values.app.name }}
template:
metadata:
labels:
app: {{ .Values.app.name }}
spec:
containers:
- name: {{ .Values.app.name }}
image: "{{ .Values.app.containers.image }}:{{ .Values.app.containers.tag }}"
ports:
- containerPort: {{ .Values.app.port }}
resources:
limits: {{ .Values.app.limits | toYaml | nindent 12 }}
requests: {{ .Values.app.requests | toYaml | nindent 12 }}
readinessProbe:
httpGet:
path: /readiness
port: {{ .Values.app.port }}
initialDelaySeconds: 5
periodSeconds: 5
livenessProbe:
httpGet:
path: /liveness
port: {{ .Values.app.port }}
initialDelaySeconds: 10
periodSeconds: 5
15 changes: 15 additions & 0 deletions devops/templates/01-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

apiVersion: v1
kind: Service
metadata:
name: service
namespace: {{ .Values.app.namespace }}
labels:
app: {{ .Values.app.name }}
spec:
selector:
app: {{ .Values.app.name }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}
type: ClusterIP
22 changes: 22 additions & 0 deletions devops/values-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
app:
name: p2p-devops-test-production
replicas: 2
namespace: p2p-devops-test-production
port: 3000
containers:
image: ghcr.io/akatruk/p2p-devops-test
tag: v0.0.3
limits:
memory: "256Mi"
cpu: "200m"
requests:
memory: "128Mi"
cpu: "100m"

service:
port: 3000

hpa:
minReplicas: 1
maxReplicas: 5
targetCPUUtilizationPercentage: 50
22 changes: 22 additions & 0 deletions devops/values-stg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
app:
name: p2p-devops-test-staging
replicas: 1
namespace: p2p-devops-test-staging
port: 3000
containers:
image: ghcr.io/akatruk/p2p-devops-test
tag: v0.0.4
limits:
memory: "256Mi"
cpu: "200m"
requests:
memory: "128Mi"
cpu: "100m"

service:
port: 3000

hpa:
minReplicas: 1
maxReplicas: 1
targetCPUUtilizationPercentage: 50
28 changes: 21 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
package main

import (
"fmt"
"net/http"
"fmt"
"net/http"
)

func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, you've requested: %s\n", r.URL.Path)
})
fmt.Println("Web app running on localhost:3000")
http.ListenAndServe(":3000", nil)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, you've requested: %s\n", r.URL.Path)
})
fmt.Println("Web app running on localhost:3000")

http.HandleFunc("/readiness", func(w http.ResponseWriter, r *http.Request) {
// Check if the application is ready to serve traffic (e.g., database connection is established)
// Return a 200 OK if ready, otherwise return a non-2xx status code.
w.WriteHeader(http.StatusOK)
})

http.HandleFunc("/liveness", func(w http.ResponseWriter, r *http.Request) {
// Check if the application is alive (e.g., by performing a simple health check)
// Return a 200 OK if alive, otherwise return a non-2xx status code.
w.WriteHeader(http.StatusOK)
})

http.ListenAndServe(":3000", nil)

}