Merge pull request #2 from KevinMidboe/kube

Kubernetes CI pipeline
This commit is contained in:
2023-11-05 00:01:40 +01:00
committed by GitHub
4 changed files with 101 additions and 5 deletions

View File

@@ -1,26 +1,29 @@
---
kind: pipeline
type: docker
name: Build and publish
name: Build
platform:
os: linux
arch: amd64
steps:
- name: lint
- name: Install dependencies
image: node:21-alpine3.17
commands:
- yarn
- name: Lint project
image: node:21-alpine3.17
commands:
- yarn lint
- name: build
- name: Build
image: node:21-alpine3.17
commands:
- yarn
- yarn build
- name: Build and publish docker image
- name: Publish to ghcr
image: plugins/docker
settings:
registry: ghcr.io
@@ -39,3 +42,34 @@ steps:
- pull_request
branch:
- main
---
kind: pipeline
type: docker
name: Deploy
platform:
os: linux
arch: amd64
steps:
- name: Deploy to kubernetes
image: alpine/k8s:1.25.15
commands:
- mkdir -p /root/.kube
- echo $KUBE_CONFIG | base64 -di > /root/.kube/config
- kubectl --kubeconfig=/root/.kube/config apply -f .kubernetes
environment:
KUBE_CONFIG:
from_secret: KUBE_CONFIG
when:
event:
include:
- push
exclude:
- pull_request
branch:
- main
depends_on:
- Build

View File

@@ -0,0 +1,5 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: k9e

View File

@@ -0,0 +1,39 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: '1'
labels:
app: k9e
name: k9e
namespace: k9e
spec:
progressDeadlineSeconds: 600
replicas: 2
revisionHistoryLimit: 10
selector:
matchLabels:
app: k9e
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: k9e
spec:
containers:
- image: ghcr.io/kevinmidboe/k9e.no:latest
imagePullPolicy: IfNotPresent
name: k9e
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30

18
.kubernetes/service.yml Normal file
View File

@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: k9e
name: k9e-service
namespace: k9e
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: k9e
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}