Bootstrapped from template.
Some checks failed
Home Cluster Builds/wedding-page/pipeline/head There was a failure building this commit

This commit is contained in:
2023-01-07 18:10:43 +02:00
parent d0689a1ae5
commit 8278950bf7
10 changed files with 124 additions and 121 deletions

68
cicd/Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,68 @@
#!groovy
pipeline {
agent {
kubernetes {
defaultContainer 'jnlp'
yaml """
apiVersion: v1
kind: Pod
metadata:
name: wedding-fe-env.BRANCH_NAME-build
spec:
serviceAccountName: jenkins-admin
containers:
- name: kaniko
image: gcr.io/kaniko-project/executor:debug
command: ["tail"]
args: ["-f", "/dev/null"]
volumeMounts:
- name: kaniko-secret
mountPath: /kaniko/.docker
- name: deploy
image: 192.168.195.195:30000/nginx:latest
command: ["tail"]
args: ["-f", "/dev/null"]
restartPolicy: Never
volumes:
- name: kaniko-secret
secret:
secretName: dockercred
items:
- key: .dockerconfigjson
path: config.json
"""
}
}
stages {
stage('Build') {
steps {
sh 'echo "No build steps configured."'
}
}
stage('Test') {
steps {
sh 'echo "No test steps configured."'
}
}
stage('Docker Build and Push') {
steps {
container("kaniko") {
sh '''
/kaniko/executor --dockerfile `pwd`/cicd/env.BRANCH_NAME/Dockerfile --context `pwd` --destination 192.168.195.195:30000/wedding-fe:env.BRANCH_NAME
'''
}
}
}
stage('Kubernetes Deploy') {
steps {
container("deploy") {
sh 'curl -LO "https://storage.googleapis.com/kubernetes-release/release/v1.24.3/bin/linux/arm64/kubectl"'
sh 'chmod u+x ./kubectl'
sh 'sed -ie "s/{{replaceMe}}/`date +%s`/g" `pwd`/cicd/env.BRANCH_NAME/deployment.yaml'
sh './kubectl replace -f `pwd`/cicd/`env.BRANCH_NAME`/deployment.yaml'
}
}
}
}
}

3
cicd/main/Dockerfile Normal file
View File

@@ -0,0 +1,3 @@
FROM 192.168.195.195:30001/nginx:latest
COPY html /usr/share/nginx/html

51
cicd/main/deployment.yaml Normal file
View File

@@ -0,0 +1,51 @@
apiVersion: v1
kind: Service
metadata:
name: wedding-fe-main-svc
namespace: apps
spec:
type: NodePort
selector:
app: wedding-fe-main
ports:
- name: http
nodePort: 31011
port: 80
targetPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: wedding-fe-main
namespace: apps
spec:
replicas: 1
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
selector:
matchLabels:
app: wedding-fe-main
template:
metadata:
labels:
app: wedding-fe-main
delpoymentDate: "{{replaceMe}}"
spec:
containers:
- name: wedding-fe-main
image: 192.168.195.195:30000/wedding-fe:main
imagePullPolicy: Always
ports:
- name: http
containerPort: 80
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 5
successThreshold: 1

3
cicd/prod/Dockerfile Normal file
View File

@@ -0,0 +1,3 @@
FROM 192.168.195.195:30001/nginx:latest
COPY html /usr/share/nginx/html

51
cicd/prod/deployment.yaml Normal file
View File

@@ -0,0 +1,51 @@
apiVersion: v1
kind: Service
metadata:
name: wedding-fe-prod-svc
namespace: apps
spec:
type: NodePort
selector:
app: wedding-fe-prod
ports:
- name: http
nodePort: 31010
port: 80
targetPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: wedding-fe-prod
namespace: apps
spec:
replicas: 2
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
selector:
matchLabels:
app: wedding-fe-prod
template:
metadata:
labels:
app: wedding-fe-prod
delpoymentDate: "{{replaceMe}}"
spec:
containers:
- name: wedding-fe-prod
image: 192.168.195.195:30000/wedding-fe:prod
imagePullPolicy: Always
ports:
- name: http
containerPort: 80
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 5
successThreshold: 1

3
cicd/stage/Dockerfile Normal file
View File

@@ -0,0 +1,3 @@
FROM 192.168.195.195:30001/nginx:latest
COPY html /usr/share/nginx/html

View File

@@ -0,0 +1,51 @@
apiVersion: v1
kind: Service
metadata:
name: wedding-fe-stage-svc
namespace: apps
spec:
type: NodePort
selector:
app: wedding-fe-stage
ports:
- name: http
nodePort: 31012
port: 80
targetPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: wedding-fe-stage
namespace: apps
spec:
replicas: 1
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
selector:
matchLabels:
app: wedding-fe-stage
template:
metadata:
labels:
app: wedding-fe-stage
delpoymentDate: "{{replaceMe}}"
spec:
containers:
- name: wedding-fe-stage
image: 192.168.195.195:30000/wedding-fe:stage
imagePullPolicy: Always
ports:
- name: http
containerPort: 80
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 5
successThreshold: 1