This commit is contained in:
Nikola Kubiczek 2023-09-25 19:28:57 +02:00
parent ae9d1f825a
commit b95d9530a9
Signed by: yaemiku
GPG Key ID: ADC039636B3E4AAB
4 changed files with 75 additions and 71 deletions

View File

@ -4,7 +4,7 @@ stages:
.kube-context:
before_script:
- if [ -n "$KUBE_CONTEXT" ]; then kubectl config use-context "$KUBE_CONTEXT"; fi
- if [ -n "$KUBE_CONTEXT" ]; then kubectl config use-context "$KUBE_CONTEXT"; fi
build:
stage: build
@ -12,28 +12,27 @@ build:
variables:
STORAGE_DRIVER: vfs
BUILDAH_FORMAT: docker
FQ_IMAGE_NAME: "$REGISTRY/yaemiku/$CI_PROJECT_NAME"
IMAGE: "$REGISTRY/$REGISTRY_USERNAME/$CI_PROJECT_NAME"
before_script:
- buildah login -u "$REGISTRY_USERNAME" -p "$REGISTRY_PASSWORD" "$REGISTRY"
script:
- buildah images
- buildah build -t $FQ_IMAGE_NAME -t $FQ_IMAGE_NAME #:$CI_COMMIT_TAG
- buildah build -t $IMAGE:latest -t $IMAGE:$CI_COMMIT_TAG
- buildah images
- buildah push --all $FQ_IMAGE_NAME
- buildah push --all $IMAGE
after_script:
- buildah logout "$REGISTRY"
# rules:
# - if: $CI_COMMIT_TAG
rules:
- if: $CI_COMMIT_TAG
deploy:
stage: deploy
when: always
extends: [.kube-context]
image:
name: bitnami/kubectl:latest
entrypoint: [""]
entrypoint: [""]
script:
- ls
- kubectl apply -f $CI_PROJECT_DIR/hamburger.yaml
- cat $CI_PROJECT_DIR/deployment.yaml | envsubst | kubectl apply -f -
- kubectl get pods
# rules:
# - if: $CI_COMMIT_TAG

65
deployment.yaml Normal file
View File

@ -0,0 +1,65 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: hamburger
spec:
selector:
matchLabels:
app: hamburger
replicas: 1
template:
metadata:
labels:
app: hamburger
spec:
containers:
- name: hamburger
image: "$REGISTRY/$REGISTRY_USERNAME/$CI_PROJECT_NAME"
ports:
- name: app-port
containerPort: 3000
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
imagePullSecrets:
- name: regcred
---
apiVersion: v1
kind: Service
metadata:
name: hamburger
spec:
ports:
- name: app-svc-port
port: 80
targetPort: app-port
selector:
app: hamburger
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: hamburger
spec:
entryPoints:
- websecure
routes:
- kind: Rule
match: Host(`yaemiku.dev`)
services:
- kind: Service
name: hamburger
port: app-svc-port
tls:
secretName: hamburger-tls
certResolver: letsencrypt-prod
domains:
- main: yaemiku.dev
sans:
- www.yaemiku.dev

View File

@ -1,60 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: hamburger
spec:
selector:
matchLabels:
app: hamburger
replicas: 1
template:
metadata:
labels:
app: hamburger
spec:
containers:
- name: hamburger
image: registry.yaemiku.dev/yaemiku/hamburger:latest
ports:
- containerPort: 3000
imagePullSecrets:
- name: regcred
---
apiVersion: v1
kind: Service
metadata:
name: hamburger
spec:
ports:
- port: 3000
name: nextjs
selector:
app: hamburger
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hamburger
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
traefik.ingress.kubernetes.io/router.middlewares: default-redirect-https@kubernetescrd
spec:
ingressClassName: traefik
rules:
- host: yaemiku.dev
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: hamburger
port:
name: nextjs
tls:
- secretName: hamburger-tls
hosts:
- yaemiku.dev

View File

@ -1,6 +1,6 @@
{
"name": "hamburger",
"version": "0.1.0",
"version": "1.0",
"private": true,
"scripts": {
"dev": "next dev",