feat(jenkins): adding new default jenkins configuration
This commit is contained in:
parent
69c6b35d17
commit
aeb5a75cf1
|
@ -0,0 +1,25 @@
|
||||||
|
// Intégration de la librairie Cadoles (voir https://forge.cadoles.com/Cadoles/Jenkins)
|
||||||
|
@Library("cadoles") _
|
||||||
|
|
||||||
|
// Utilisation du pipeline partagé pour les applications Symfony de Cadoles
|
||||||
|
// Le nom de l'image Docker passée en paramètre vous permet de préciser l'environnement de test
|
||||||
|
// de votre application Symfony
|
||||||
|
symfonyAppPipeline('ubuntu:22.04', [
|
||||||
|
'hooks': [
|
||||||
|
// Run docker image build, verification and publication stages
|
||||||
|
'postSymfonyAppPipeline': {
|
||||||
|
stage('Build and publish docker images') {
|
||||||
|
// Retrieve current tag
|
||||||
|
String currentTag = sh(script: 'git tag --points-at HEAD | head -n 1', returnStdout: true).trim()
|
||||||
|
// Retrieve default tag
|
||||||
|
String defaultTag = sh(returnStdout: true, script: 'git describe --always').trim()
|
||||||
|
kubecontainer.buildAndPublishImage([
|
||||||
|
'imageName': 'reg.cadoles.com/pcaseiro/myapplication-standalone',
|
||||||
|
'imageTag': defaultTag,
|
||||||
|
'dockerfile': './misc/images/myapplication-standalone/Dockerfile',
|
||||||
|
'dryRun': false
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
])
|
14
Makefile
14
Makefile
|
@ -1,10 +1,12 @@
|
||||||
################################
|
##################################################
|
||||||
# Makefile for Cadoles SP
|
# Makefile for Cadoles Kubernetes Skeletor project
|
||||||
################################
|
##################################################
|
||||||
|
|
||||||
IMAGE_REPO := reg.cadoles.com/cadoles
|
COMMIT_ID ?= $(shell git rev-parse --short --verify HEAD)
|
||||||
IMAGE_VERSION ?= 0.0.1
|
CURRENT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD | tr -c '[:alnum:]\n\r' '_'| tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
|
IMAGE_REPO ?= reg.cadoles.com/cadoles
|
||||||
|
IMAGE_VERSION ?= 0.0.1-$(CURRENT_BRANCH)
|
||||||
|
|
||||||
DAY_SUFFIX_TAG ?= $(shell date +%Y%m%d)
|
|
||||||
|
|
||||||
include main.mk
|
include main.mk
|
||||||
|
|
16
init-app
16
init-app
|
@ -79,26 +79,26 @@ init_app() {
|
||||||
rm -rf .git
|
rm -rf .git
|
||||||
|
|
||||||
echo "Setting Dockerfiles"
|
echo "Setting Dockerfiles"
|
||||||
dirs=$(find ${DOCKERFILES_ROOT}/* -type d -name 'MYAPPLICATION-*')
|
dirs=$(find ${DOCKERFILES_ROOT}/* -type d -name 'myapplication-*')
|
||||||
for d in ${dirs}; do
|
for d in ${dirs}; do
|
||||||
mv ${d} $(echo ${d} | sed "s/MYAPPLICATION/${appName}/g")
|
mv ${d} $(echo ${d} | sed "s/myapplication/${appName}/g")
|
||||||
done
|
done
|
||||||
echo "Setting Kustomization directories"
|
echo "Setting Kustomization directories"
|
||||||
dirs=$(find ${KUSTOMIZE_DIR}/* -type d -name 'MYAPPLICATION-*')
|
dirs=$(find ${KUSTOMIZE_DIR}/* -type d -name 'myapplication-*')
|
||||||
for d in ${dirs}; do
|
for d in ${dirs}; do
|
||||||
mv ${d} $(echo ${d} | sed "s/MYAPPLICATION/${appName}/g")
|
mv ${d} $(echo ${d} | sed "s/myapplication/${appName}/g")
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Setting Kustomization files"
|
echo "Setting Kustomization files"
|
||||||
dirs=$(find ${KUSTOMIZE_DIR}/* -type f -name 'MYAPPLICATION-*')
|
dirs=$(find ${KUSTOMIZE_DIR}/* -type f -name 'myapplication-*')
|
||||||
for d in ${dirs}; do
|
for d in ${dirs}; do
|
||||||
mv ${d} $(echo ${d} | sed "s/MYAPPLICATION/${appName}/g")
|
mv ${d} $(echo ${d} | sed "s/myapplication/${appName}/g")
|
||||||
done
|
done
|
||||||
|
|
||||||
grep -rl "MYAPPLICATION" ${KUSTOMIZE_DIR} | xargs sed -i "s/MYAPPLICATION/${appName}/g"
|
grep -rl "myapplication" ${KUSTOMIZE_DIR} | xargs sed -i "s/myapplication/${appName}/g"
|
||||||
|
|
||||||
echo "Setting Skaffold configuration"
|
echo "Setting Skaffold configuration"
|
||||||
sed -i "s/MYAPPLICATION/${appName}/g" ${appDest}/skaffold.yaml
|
sed -i "s/myapplication/${appName}/g" ${appDest}/skaffold.yaml
|
||||||
|
|
||||||
echo "Setting docker registry secrets"
|
echo "Setting docker registry secrets"
|
||||||
create_docker_secret ${conf}
|
create_docker_secret ${conf}
|
||||||
|
|
13
main.mk
13
main.mk
|
@ -28,12 +28,12 @@ define install_trivy
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define release_image
|
define release_image
|
||||||
docker tag $(IMAGE_REPO)/$1:$(IMAGE_VERSION) $(IMAGE_REPO)/$1:$(IMAGE_VERSION)-$(DAY_SUFFIX_TAG) ; \
|
docker tag $(IMAGE_REPO)/$1:$(IMAGE_VERSION) $(IMAGE_REPO)/$1:$(IMAGE_VERSION)-$(COMMIT_ID) ; \
|
||||||
docker tag $(IMAGE_REPO)/$1:$(IMAGE_VERSION) $(IMAGE_REPO)/$1:$(IMAGE_VERSION); \
|
docker tag $(IMAGE_REPO)/$1:$(IMAGE_VERSION) $(IMAGE_REPO)/$1:$(IMAGE_VERSION); \
|
||||||
docker tag $(IMAGE_REPO)/$1:$(IMAGE_VERSION) $(IMAGE_REPO)/$1:latest ; \
|
docker tag $(IMAGE_REPO)/$1:$(IMAGE_VERSION) $(IMAGE_REPO)/$1:$(IMAGE_VERSION)-latest; \
|
||||||
docker push $(IMAGE_REPO)/$1:latest ; \
|
docker push $(IMAGE_REPO)/$1:$(IMAGE_VERSION)-latest ; \
|
||||||
docker push $(IMAGE_REPO)/$1:$(IMAGE_VERSION) ; \
|
docker push $(IMAGE_REPO)/$1:$(IMAGE_VERSION) ; \
|
||||||
docker push $(IMAGE_REPO)/$1:$(IMAGE_VERSION)-$(DAY_SUFFIX_TAG)
|
docker push $(IMAGE_REPO)/$1:$(IMAGE_VERSION)-$(COMMIT_ID)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
#list:
|
#list:
|
||||||
|
@ -57,9 +57,12 @@ release: ${IMAGES_DIR}/*
|
||||||
@for name in $(basename $(notdir $^)); do \
|
@for name in $(basename $(notdir $^)); do \
|
||||||
$(call release_image,$${name},base); \
|
$(call release_image,$${name},base); \
|
||||||
done;\
|
done;\
|
||||||
|
git tag -f -a $(IMAGE_VERSION) -m "Version $(IMAGE_VERSION) released"; \
|
||||||
|
git tag -f -a $(IMAGE_VERSION)-$(COMMIT_ID) -m "Version $(IMAGE_VERSION)-$(COMMIT_ID) released"; \
|
||||||
|
git tag -f -a $(IMAGE_VERSION)-latest -m "Version $(IMAGE_VERSION)-latest released"; \
|
||||||
|
|
||||||
_release:
|
_release:
|
||||||
docker tag $(IMAGE_FULL_NAME):$(IMAGE_TAG) $(IMAGE_FULL_NAME):$(IMAGE_TAG)-$(IMAGE_VERSION)-$(DAY_SUFFIX_TAG)
|
docker tag $(IMAGE_FULL_NAME):$(IMAGE_TAG) $(IMAGE_FULL_NAME):$(IMAGE_TAG)-$(IMAGE_VERSION)-$(COMMIT_ID)
|
||||||
docker tag $(IMAGE_FULL_NAME):$(IMAGE_TAG) $(IMAGE_FULL_NAME):$(IMAGE_TAG)-$(IMAGE_VERSION)
|
docker tag $(IMAGE_FULL_NAME):$(IMAGE_TAG) $(IMAGE_FULL_NAME):$(IMAGE_TAG)-$(IMAGE_VERSION)
|
||||||
docker tag $(IMAGE_FULL_NAME):$(IMAGE_TAG) $(IMAGE_FULL_NAME):$(IMAGE_TAG)-latest
|
docker tag $(IMAGE_FULL_NAME):$(IMAGE_TAG) $(IMAGE_FULL_NAME):$(IMAGE_TAG)-latest
|
||||||
docker push $(IMAGE_FULL_NAME):$(IMAGE_TAG)-$(IMAGE_VERSION)-$(DAY_SUFFIX_TAG)
|
docker push $(IMAGE_FULL_NAME):$(IMAGE_TAG)-$(IMAGE_VERSION)-$(DAY_SUFFIX_TAG)
|
||||||
|
|
|
@ -8,24 +8,24 @@ configurations:
|
||||||
- ./configurations/cnpg-cluster.yaml
|
- ./configurations/cnpg-cluster.yaml
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
- ./resources/MYAPPLICATION-cnpg-cluster.yaml
|
- ./resources/myapplication-cnpg-cluster.yaml
|
||||||
|
|
||||||
secretgenerator:
|
secretgenerator:
|
||||||
- name: MYAPPLICATION-postgres-admin
|
- name: myapplication-postgres-admin
|
||||||
type: secret
|
type: secret
|
||||||
literals:
|
literals:
|
||||||
- username=postgres
|
- username=postgres
|
||||||
- password=notsosecret
|
- password=notsosecret
|
||||||
- name: MYAPPLICATION-postgres-user
|
- name: myapplication-postgres-user
|
||||||
type: Secret
|
type: Secret
|
||||||
literals:
|
literals:
|
||||||
- username=MYAPPLICATION
|
- username=myapplication
|
||||||
- password=NotSoSecretButThisIsBad
|
- password=NotSoSecretButThisIsBad
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
- name: MYAPPLICATION_DATABASE_SERVICE_NAME
|
- name: myapplication_DATABASE_SERVICE_NAME
|
||||||
objref:
|
objref:
|
||||||
name: MYAPPLICATION-postgres
|
name: myapplication-postgres
|
||||||
kind: Cluster
|
kind: Cluster
|
||||||
apiVersion: postgresql.cnpg.io/v1
|
apiVersion: postgresql.cnpg.io/v1
|
||||||
fieldref:
|
fieldref:
|
|
@ -1,17 +1,17 @@
|
||||||
apiVersion: postgresql.cnpg.io/v1
|
apiVersion: postgresql.cnpg.io/v1
|
||||||
kind: Cluster
|
kind: Cluster
|
||||||
metadata:
|
metadata:
|
||||||
name: MYAPPLICATION-postgres
|
name: myapplication-postgres
|
||||||
spec:
|
spec:
|
||||||
instances: 3
|
instances: 3
|
||||||
primaryUpdateStrategy: unsupervised
|
primaryUpdateStrategy: unsupervised
|
||||||
superuserSecret:
|
superuserSecret:
|
||||||
name: MYAPPLICATION-postgres-admin
|
name: myapplication-postgres-admin
|
||||||
bootstrap:
|
bootstrap:
|
||||||
initdb:
|
initdb:
|
||||||
database: MYAPPLICATION
|
database: myapplication
|
||||||
owner: MYAPPLICATION
|
owner: myapplication
|
||||||
secret:
|
secret:
|
||||||
name: MYAPPLICATION-postgres-user
|
name: myapplication-postgres-user
|
||||||
storage:
|
storage:
|
||||||
size: 20Gi
|
size: 20Gi
|
|
@ -1,10 +1,10 @@
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|
||||||
namePrefix: MYAPPLICATION-
|
namePrefix: myapplication-
|
||||||
|
|
||||||
components:
|
components:
|
||||||
- components/MYAPPLICATION-cnpg
|
- components/myapplication-cnpg
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
- resources/MYAPPLICATION-kube
|
- resources/myapplication-kube
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
||||||
kind: Kustomization
|
|
||||||
|
|
||||||
resources:
|
|
||||||
- ./resources/MYAPPLICATION-service.yaml
|
|
||||||
- ./resources/MYAPPLICATION-deployment.yaml
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- ./resources/myapplication-service.yaml
|
||||||
|
- ./resources/myapplication-deployment.yaml
|
|
@ -2,26 +2,26 @@ apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
io.kompose.service: MYAPPLICATION
|
io.kompose.service: myapplication
|
||||||
name: MYAPPLICATION
|
name: myapplication
|
||||||
spec:
|
spec:
|
||||||
replicas: 3
|
replicas: 3
|
||||||
|
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
io.kompose.service: MYAPPLICATION
|
io.kompose.service: myapplication
|
||||||
strategy:
|
strategy:
|
||||||
type: Recreate
|
type: Recreate
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
io.kompose.service: MYAPPLICATION
|
io.kompose.service: myapplication
|
||||||
spec:
|
spec:
|
||||||
restartPolicy: Always
|
restartPolicy: Always
|
||||||
containers:
|
containers:
|
||||||
- image: reg.cadoles.com/cadoles/MYAPPLICATION-kube
|
- image: reg.cadoles.com/cadoles/myapplication-kube
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
name: MYAPPLICATION-php-fpm
|
name: myapplication-php-fpm
|
||||||
args: ["/usr/sbin/php-fpm81", "-F", "-e"]
|
args: ["/usr/sbin/php-fpm81", "-F", "-e"]
|
||||||
resources: {}
|
resources: {}
|
||||||
env:
|
env:
|
||||||
|
@ -33,22 +33,22 @@ spec:
|
||||||
value: 128m
|
value: 128m
|
||||||
- name: PHP_FPM_LOG_LEVEL
|
- name: PHP_FPM_LOG_LEVEL
|
||||||
value: warning
|
value: warning
|
||||||
- name: MYAPPLICATION_DATABASE_SERVICE_NAME
|
- name: myapplication_DATABASE_SERVICE_NAME
|
||||||
value: $(MYAPPLICATION_DATABASE_SERVICE_NAME)-rw
|
value: $(myapplication_DATABASE_SERVICE_NAME)-rw
|
||||||
- image: reg.cadoles.com/cadoles/MYAPPLICATION-kube
|
- image: reg.cadoles.com/cadoles/myapplication-kube
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
name: MYAPPLICATION-nginx
|
name: myapplication-nginx
|
||||||
args: ["/usr/sbin/nginx"]
|
args: ["/usr/sbin/nginx"]
|
||||||
env:
|
env:
|
||||||
- name: NGINX_MYAPPLICATION_UPSTREAM_BACKEND_SERVER
|
- name: NGINX_myapplication_UPSTREAM_BACKEND_SERVER
|
||||||
value: 127.0.0.1:9000
|
value: 127.0.0.1:9000
|
||||||
- name: NGINX_MYAPPLICATION_ROOT
|
- name: NGINX_myapplication_ROOT
|
||||||
value: "/public"
|
value: "/public"
|
||||||
- name: NGINX_MYAPPLICATION_PHP_INDEX
|
- name: NGINX_myapplication_PHP_INDEX
|
||||||
value: "/index.php"
|
value: "/index.php"
|
||||||
- name: NGINX_ERROR_LOG_LEVEL
|
- name: NGINX_ERROR_LOG_LEVEL
|
||||||
value: "warn"
|
value: "warn"
|
||||||
- name: NGINX_MYAPPLICATION_PHP_NON_FILE_PATTERN
|
- name: NGINX_myapplication_PHP_NON_FILE_PATTERN
|
||||||
value: "^/index\\.php(/|$)"
|
value: "^/index\\.php(/|$)"
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
|
@ -2,13 +2,13 @@ apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
io.kompose.service: MYAPPLICATION
|
io.kompose.service: myapplication
|
||||||
name: MYAPPLICATION
|
name: myapplication
|
||||||
spec:
|
spec:
|
||||||
type: ClusterIP
|
type: ClusterIP
|
||||||
ports:
|
ports:
|
||||||
- name: MYAPPLICATION-http
|
- name: myapplication-http
|
||||||
port: 80
|
port: 80
|
||||||
targetPort: 8080
|
targetPort: 8080
|
||||||
selector:
|
selector:
|
||||||
io.kompose.service: MYAPPLICATION
|
io.kompose.service: myapplication
|
|
@ -1,6 +1,6 @@
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
namespace: MYAPPLICATION-dev
|
namespace: myapplication-dev
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
- ../../base
|
- ../../base
|
||||||
|
@ -8,7 +8,7 @@ resources:
|
||||||
- resources/ingress.yaml
|
- resources/ingress.yaml
|
||||||
|
|
||||||
patches:
|
patches:
|
||||||
- path: patches/MYAPPLICATION-update-replicas.yaml
|
- path: patches/myapplication-update-replicas.yaml
|
||||||
- path: patches/add-registry-pull-secret.yaml
|
- path: patches/add-registry-pull-secret.yaml
|
||||||
target:
|
target:
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
- op: add
|
|
||||||
path: "/spec/template/spec/imagePullSecrets"
|
|
||||||
value:
|
|
||||||
- name: regcred-dev
|
|
|
@ -2,7 +2,7 @@ apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
io.kompose.service: MYAPPLICATION
|
io.kompose.service: myapplication
|
||||||
name: MYAPPLICATION
|
name: myapplication
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: 1
|
|
@ -1,7 +1,7 @@
|
||||||
apiVersion: networking.k8s.io/v1
|
apiVersion: networking.k8s.io/v1
|
||||||
kind: Ingress
|
kind: Ingress
|
||||||
metadata:
|
metadata:
|
||||||
name: MYAPPLICATION
|
name: myapplication
|
||||||
annotations:
|
annotations:
|
||||||
nginx.ingress.kubernetes.io/proxy-body-size: "138m"
|
nginx.ingress.kubernetes.io/proxy-body-size: "138m"
|
||||||
nginx.ingress.kubernetes.io/enable-cors: "true" #cf 01
|
nginx.ingress.kubernetes.io/enable-cors: "true" #cf 01
|
||||||
|
@ -9,13 +9,13 @@ metadata:
|
||||||
spec:
|
spec:
|
||||||
ingressClassName: nginx
|
ingressClassName: nginx
|
||||||
rules:
|
rules:
|
||||||
- host: MYAPPLICATION.dev.local
|
- host: myapplication.dev.local
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
pathType: Prefix
|
pathType: Prefix
|
||||||
backend:
|
backend:
|
||||||
service:
|
service:
|
||||||
name: MYAPPLICATION
|
name: myapplication
|
||||||
port:
|
port:
|
||||||
number: 8080
|
number: 8080
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
metadata:
|
metadata:
|
||||||
name: MYAPPLICATION-dev
|
name: myapplication-dev
|
||||||
|
|
|
@ -29,7 +29,7 @@ build:
|
||||||
sha256: {}
|
sha256: {}
|
||||||
|
|
||||||
artifacts:
|
artifacts:
|
||||||
- image: reg.cadoles.com/cadoles/MYAPPLICATION-kube
|
- image: reg.cadoles.com/cadoles/myapplication-kube
|
||||||
context: .
|
context: .
|
||||||
sync:
|
sync:
|
||||||
infer:
|
infer:
|
||||||
|
@ -41,7 +41,7 @@ build:
|
||||||
- composer.json
|
- composer.json
|
||||||
- composer.lock
|
- composer.lock
|
||||||
kaniko:
|
kaniko:
|
||||||
dockerfile: misc/images/MYAPPLICATION-kube/Dockerfile
|
dockerfile: misc/images/myapplication-kube/Dockerfile
|
||||||
cache: {}
|
cache: {}
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
|
|
Loading…
Reference in New Issue