Compare commits
17 Commits
ce05fb4edc
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| c5ed7929dd | |||
| 994fd12a47 | |||
| 4e099de25d | |||
| 6934f6b510 | |||
| 2de9a0a1b4 | |||
| 0c29b440fb | |||
| 6d84f34159 | |||
| 9969093c91 | |||
| 6b201ad7b8 | |||
| 08434311b5 | |||
| 4c1844b344 | |||
| 342710efd3 | |||
| 3236ec9925 | |||
| c51b9b8af3 | |||
| 90247939dc | |||
| 3da8c0548a | |||
| 1310a684b8 |
@@ -1,4 +1,4 @@
|
|||||||
name: CI/CD Pipeline
|
name: CI/CD Pipeline popravak
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -18,7 +18,7 @@ jobs:
|
|||||||
- name: Login u Gitea registry
|
- name: Login u Gitea registry
|
||||||
run: |
|
run: |
|
||||||
echo ${{ secrets.REGISTRY_PASS }} | \
|
echo ${{ secrets.REGISTRY_PASS }} | \
|
||||||
docker login $REGISTRY \
|
docker login git.fpmoz.sum.ba \
|
||||||
-u ${{ secrets.REGISTRY_USER }} --password-stdin
|
-u ${{ secrets.REGISTRY_USER }} --password-stdin
|
||||||
|
|
||||||
- name: Build i Push image
|
- name: Build i Push image
|
||||||
@@ -46,23 +46,25 @@ jobs:
|
|||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: image-tag
|
name: image-tag
|
||||||
|
|
||||||
- name: Instaliraj kubectl
|
- name: Instaliraj kubectl
|
||||||
uses: azure/setup-kubectl@v3
|
uses: azure/setup-kubectl@v3
|
||||||
with:
|
with:
|
||||||
version: 'latest'
|
version: 'latest'
|
||||||
- name: Postavi kubeconfig
|
- name: Postavi kubeconfig
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.kube
|
# 1. Uzimamo tvoj plavi kod i pretvaramo ga nazad u pravu datoteku
|
||||||
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > ~/.kube/config
|
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > kubeconfig
|
||||||
chmod 600 ~/.kube/config
|
chmod 600 kubeconfig
|
||||||
|
|
||||||
- name: Update image tag u manifestu
|
- name: Update image tag u manifestu
|
||||||
run: |
|
run: |
|
||||||
TAG=$(cat tag.txt)
|
TAG=$(cat tag.txt)
|
||||||
sed -i "s|image:.*|image: $IMAGE:$TAG|" k8s/deployment.yaml
|
IMAGE="ghcr.io/sz11zs/hello-cicd"
|
||||||
|
sed -i "s|image:.*|image: $IMAGE:$TAG|" k8s/deployment.yaml
|
||||||
- name: Deploy na k3s
|
- name: Deploy na k3s
|
||||||
run: |
|
run: |
|
||||||
kubectl apply -f k8s/
|
# 2. DODATAK: Prisiljavamo kubectl da gleda baš tu datoteku, a ne 127.0.0.1
|
||||||
kubectl rollout status deployment/hello-cicd \
|
export KUBECONFIG=$GITHUB_WORKSPACE/kubeconfig
|
||||||
-n student-${{ github.actor }} --timeout=120s
|
kubectl apply -f k8s/ --validate=false
|
||||||
|
kubectl rollout status deployment/hello-cicd -n student-sz11zs --timeout=120s
|
||||||
@@ -1,58 +1,28 @@
|
|||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: moj-servis
|
name: hello-cicd
|
||||||
namespace: student-sz11zs
|
namespace: student-sz11zs
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: moj-servis
|
app: hello-cicd
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: moj-servis
|
app: hello-cicd
|
||||||
spec:
|
spec:
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: gitea-creds
|
- name: gitea-creds
|
||||||
containers:
|
containers:
|
||||||
- name: moj-servis
|
- name: hello-cicd
|
||||||
image: git.fpmoz.sum.ba/sz11zs/moj-servis:1.1
|
image: git.fpmoz.sum.ba/sz11zs/hello-cicd:latest
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8000
|
- containerPort: 8000
|
||||||
|
|
||||||
# 1. POVEZIVANJE S OKOLINSKIM VARIJABLAMA (Secret i ConfigMap)
|
|
||||||
env:
|
env:
|
||||||
- name: DB_PASSWORD
|
- name: APP_VERSION
|
||||||
valueFrom:
|
value: "latest"
|
||||||
secretKeyRef:
|
resources:
|
||||||
name: moj-servis-secret
|
requests: {cpu: 50m, memory: 64Mi}
|
||||||
key: DB_PASSWORD
|
limits: {cpu: 200m, memory: 128Mi}
|
||||||
- name: API_KEY
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: moj-servis-secret
|
|
||||||
key: API_KEY
|
|
||||||
envFrom:
|
|
||||||
- configMapRef:
|
|
||||||
name: moj-servis-config
|
|
||||||
|
|
||||||
# 2. LIVENESS PROBE: Dodano za Korak 1.4
|
|
||||||
livenessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /health
|
|
||||||
port: 8000
|
|
||||||
initialDelaySeconds: 10
|
|
||||||
periodSeconds: 15
|
|
||||||
timeoutSeconds: 3
|
|
||||||
failureThreshold: 3
|
|
||||||
|
|
||||||
# 3. READINESS PROBE: Dodano za Korak 1.4
|
|
||||||
readinessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /health
|
|
||||||
port: 8000
|
|
||||||
initialDelaySeconds: 5
|
|
||||||
periodSeconds: 10
|
|
||||||
timeoutSeconds: 2
|
|
||||||
failureThreshold: 2
|
|
||||||
|
|||||||
Reference in New Issue
Block a user