mirror of
https://github.com/bvanroll/cicdTest.git
synced 2025-08-29 12:02:47 +00:00
tga werke
This commit is contained in:
54
deploy.yaml
54
deploy.yaml
@@ -1,3 +1,5 @@
|
|||||||
|
#TODO ZORG ERVOOR DAT DEZE DEPLOYMENTS ENKEL DE CORRECTE ITEMS DEPLOYEN
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
# apiVersion: v1
|
# apiVersion: v1
|
||||||
# kind: Namespace
|
# kind: Namespace
|
||||||
@@ -5,32 +7,32 @@
|
|||||||
# name: istio-project-1
|
# name: istio-project-1
|
||||||
# labels:
|
# labels:
|
||||||
# istio-injection: enabled #zorgt voor auto sidecar injection
|
# istio-injection: enabled #zorgt voor auto sidecar injection
|
||||||
# ---
|
---
|
||||||
# apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
# kind: Deployment
|
kind: Deployment
|
||||||
# metadata:
|
metadata:
|
||||||
# name: server-a
|
name: server-a
|
||||||
# namespace: istio-project-1
|
namespace: istio-project-1
|
||||||
# spec:
|
spec:
|
||||||
# replicas: 1
|
replicas: 1
|
||||||
# selector:
|
selector:
|
||||||
# matchLabels:
|
matchLabels:
|
||||||
# server: "http"
|
server: "http"
|
||||||
# app: "project-1" #app label bepaald groepering pods in kiali dashboard dus makkelijker te gebruiken
|
app: "project-1" #app label bepaald groepering pods in kiali dashboard dus makkelijker te gebruiken
|
||||||
# expose: "true"
|
expose: "true"
|
||||||
# template:
|
template:
|
||||||
# metadata:
|
metadata:
|
||||||
# labels:
|
labels:
|
||||||
# server: "http"
|
server: "http"
|
||||||
# app: "project-1"
|
app: "project-1"
|
||||||
# expose: "true"
|
expose: "true"
|
||||||
# spec:
|
spec:
|
||||||
# containers:
|
containers:
|
||||||
# - name: front-end
|
- name: front-end
|
||||||
# image: beppev/server-a:master
|
image: beppev/server-a:master
|
||||||
# imagePullPolicy: "Always"
|
imagePullPolicy: "Always"
|
||||||
# ports:
|
ports:
|
||||||
# - containerPort: 5000
|
- containerPort: 5000
|
||||||
# ---
|
# ---
|
||||||
# apiVersion: apps/v1
|
# apiVersion: apps/v1
|
||||||
# kind: Deployment
|
# kind: Deployment
|
||||||
|
14
infra.yaml
Normal file
14
infra.yaml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: expose-service
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
expose: "true"
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
protocol: TCP
|
||||||
|
port: 5000
|
||||||
|
targetPort: 5000
|
||||||
|
nodePort: 30036
|
||||||
|
type: NodePort
|
@@ -57,50 +57,105 @@ subjects:
|
|||||||
name: service-acc
|
name: service-acc
|
||||||
namespace: default
|
namespace: default
|
||||||
---
|
---
|
||||||
|
# TODO add git clone task
|
||||||
apiVersion: tekton.dev/v1alpha1
|
apiVersion: tekton.dev/v1alpha1
|
||||||
kind: PipelineResource
|
kind: Task
|
||||||
metadata:
|
metadata:
|
||||||
name: git-master
|
name: git-clone
|
||||||
#namespace: stage-tekton-pipeline
|
|
||||||
spec:
|
spec:
|
||||||
type: git
|
workspaces:
|
||||||
|
- name: output
|
||||||
|
description: The git repo will be cloned onto the volume backing this workspace
|
||||||
params:
|
params:
|
||||||
- name: revision
|
|
||||||
value: master
|
|
||||||
- name: url
|
- name: url
|
||||||
value: git://github.com/beppevanrolleghem/cicdTest
|
description: git url to clone
|
||||||
|
type: string
|
||||||
|
- name: revision
|
||||||
|
description: git revision to checkout (branch, tag, sha, ref…)
|
||||||
|
type: string
|
||||||
|
default: master
|
||||||
|
- name: submodules
|
||||||
|
description: defines if the resource should initialize and fetch the submodules
|
||||||
|
type: string
|
||||||
|
default: "true"
|
||||||
|
- name: depth
|
||||||
|
description: performs a shallow clone where only the most recent commit(s) will be fetched
|
||||||
|
type: string
|
||||||
|
default: "1"
|
||||||
|
- name: sslVerify
|
||||||
|
description: defines if http.sslVerify should be set to true or false in the global git config
|
||||||
|
type: string
|
||||||
|
default: "true"
|
||||||
|
- name: subdirectory
|
||||||
|
description: subdirectory inside the "output" workspace to clone the git repo into
|
||||||
|
type: string
|
||||||
|
default: "src"
|
||||||
|
- name: deleteExisting
|
||||||
|
description: clean out the contents of the repo's destination directory (if it already exists) before trying to clone the repo there
|
||||||
|
type: string
|
||||||
|
default: "true"
|
||||||
|
results:
|
||||||
|
- name: commit
|
||||||
|
description: The precise commit SHA that was fetched by this Task
|
||||||
|
steps:
|
||||||
|
- name: clone
|
||||||
|
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:latest
|
||||||
|
script: |
|
||||||
|
CHECKOUT_DIR="$(workspaces.output.path)/$(inputs.params.subdirectory)"
|
||||||
|
cleandir() {
|
||||||
|
# Delete any existing contents of the repo directory if it exists.
|
||||||
|
#
|
||||||
|
# We don't just "rm -rf $CHECKOUT_DIR" because $CHECKOUT_DIR might be "/"
|
||||||
|
# or the root of a mounted volume.
|
||||||
|
if [[ -d "$CHECKOUT_DIR" ]] ; then
|
||||||
|
# Delete non-hidden files and directories
|
||||||
|
rm -rf "$CHECKOUT_DIR"/*
|
||||||
|
# Delete files and directories starting with . but excluding ..
|
||||||
|
rm -rf "$CHECKOUT_DIR"/.[!.]*
|
||||||
|
# Delete files and directories starting with .. plus any other character
|
||||||
|
rm -rf "$CHECKOUT_DIR"/..?*
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
if [[ "$(inputs.params.deleteExisting)" == "true" ]] ; then
|
||||||
|
cleandir
|
||||||
|
ls -lah "$CHECKOUT_DIR"
|
||||||
|
fi
|
||||||
|
/ko-app/git-init \
|
||||||
|
-url "$(inputs.params.url)" \
|
||||||
|
-revision "$(inputs.params.revision)" \
|
||||||
|
-path "$CHECKOUT_DIR" \
|
||||||
|
-sslVerify "$(inputs.params.sslVerify)" \
|
||||||
|
-submodules "$(inputs.params.submodules)" \
|
||||||
|
-depth "$(inputs.params.depth)"
|
||||||
|
cd "$CHECKOUT_DIR"
|
||||||
|
RESULT_SHA="$(git rev-parse HEAD | tr -d '\n')"
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
if [ "$EXIT_CODE" != 0 ]
|
||||||
|
then
|
||||||
|
exit $EXIT_CODE
|
||||||
|
fi
|
||||||
|
# Make sure we don't add a trailing newline to the result!
|
||||||
|
echo -n "$RESULT_SHA" > $(results.commit.path)
|
||||||
---
|
---
|
||||||
apiVersion: tekton.dev/v1alpha1
|
apiVersion: tekton.dev/v1alpha1
|
||||||
kind: PipelineResource
|
|
||||||
metadata:
|
|
||||||
name: git-experimental
|
|
||||||
#namespace: stage-tekton-pipeline
|
|
||||||
spec:
|
|
||||||
type: git
|
|
||||||
params:
|
|
||||||
- name: revision
|
|
||||||
value: experimental
|
|
||||||
- name: url
|
|
||||||
value: git://github.com/beppevanrolleghem/cicdTest
|
|
||||||
---
|
|
||||||
apiVersion: tekton.dev/v1beta1
|
|
||||||
kind: Task
|
kind: Task
|
||||||
metadata:
|
metadata:
|
||||||
name: build-and-push
|
name: build-and-push
|
||||||
#namespace: stage-tekton-pipeline
|
|
||||||
spec:
|
spec:
|
||||||
inputs:
|
|
||||||
resources:
|
|
||||||
- name: git-source
|
|
||||||
type: git
|
|
||||||
params:
|
params:
|
||||||
- name: context
|
- name: context
|
||||||
description: The path to the build context, used by Kaniko - within the workspace
|
description: The path to the build context, used by Kaniko - within the workspace
|
||||||
default: .
|
default: .
|
||||||
|
type: string
|
||||||
- name: image-name
|
- name: image-name
|
||||||
description: dockerhub url
|
description: dockerhub url
|
||||||
|
type: string
|
||||||
- name: version
|
- name: version
|
||||||
description: image-version (for instance latest or beta)
|
description: image-version (for instance latest or beta)
|
||||||
|
type: string
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
mountpath: /source
|
||||||
steps:
|
steps:
|
||||||
- name: build-and-push
|
- name: build-and-push
|
||||||
image: gcr.io/kaniko-project/executor
|
image: gcr.io/kaniko-project/executor
|
||||||
@@ -110,135 +165,143 @@ spec:
|
|||||||
command:
|
command:
|
||||||
- /kaniko/executor
|
- /kaniko/executor
|
||||||
args:
|
args:
|
||||||
- "--dockerfile=$(inputs.resources.git-source.path)/$(inputs.params.context)/dockerfile"
|
- "--dockerfile=/source/$(params.context)/dockerfile"
|
||||||
- "--destination=beppev/$(inputs.params.image-name):$(inputs.params.version)"
|
- "--destination=beppev/$(params.image-name):$(params.version)"
|
||||||
- "--context=$(inputs.resources.git-source.path)/$(inputs.params.context)/"
|
- "--context=/source/$(params.context)/"
|
||||||
---
|
---
|
||||||
apiVersion: tekton.dev/v1alpha1
|
apiVersion: tekton.dev/v1alpha1
|
||||||
kind: Task
|
kind: Task
|
||||||
metadata:
|
metadata:
|
||||||
name: destroy-application
|
name: execute-yaml
|
||||||
#namespace: stage-tekton-pipeline
|
#namespace: stage-tekton-pipeline
|
||||||
spec:
|
spec:
|
||||||
inputs:
|
params:
|
||||||
resources:
|
- name: yaml-location
|
||||||
- name: git-source
|
default: deploy.yaml
|
||||||
type: git
|
- name: command
|
||||||
steps:
|
default: apply
|
||||||
- name: delete-old-deployment
|
workspaces:
|
||||||
image: lachlanevenson/k8s-kubectl
|
- name: source
|
||||||
command: ["kubectl"]
|
mountpath: /source
|
||||||
args:
|
|
||||||
- "delete"
|
|
||||||
- "--ignore-not-found"
|
|
||||||
- "-f"
|
|
||||||
- "$(inputs.resources.git-source.path)/deploy.yaml"
|
|
||||||
---
|
|
||||||
apiVersion: tekton.dev/v1alpha1
|
|
||||||
kind: Task
|
|
||||||
metadata:
|
|
||||||
name: deploy-application
|
|
||||||
#namespace: stage-tekton-pipeline
|
|
||||||
spec:
|
|
||||||
inputs:
|
|
||||||
resources:
|
|
||||||
- name: git-source
|
|
||||||
type: git
|
|
||||||
steps:
|
steps:
|
||||||
- name: deploy-new-app
|
- name: deploy-new-app
|
||||||
image: lachlanevenson/k8s-kubectl
|
image: lachlanevenson/k8s-kubectl
|
||||||
command: ["kubectl"]
|
command: ["kubectl"]
|
||||||
args:
|
args:
|
||||||
- "apply"
|
- "$(params.command)"
|
||||||
- "-f"
|
- "-f"
|
||||||
- "$(inputs.resources.git-source.path)/deploy.yaml"
|
- "/source/$(params.yaml-location)"
|
||||||
---
|
---
|
||||||
apiVersion: tekton.dev/v1alpha1
|
apiVersion: tekton.dev/v1beta1
|
||||||
kind: Pipeline
|
kind: Pipeline
|
||||||
metadata:
|
metadata:
|
||||||
name: application-pipeline
|
name: application-pipeline
|
||||||
#namespace: stage-tekton-pipeline
|
#namespace: stage-tekton-pipeline
|
||||||
spec:
|
spec:
|
||||||
resources:
|
params:
|
||||||
- name: git-master
|
- name: git-url
|
||||||
type: git
|
description: url of the github repository to clone
|
||||||
- name: git-experimental
|
- name: branch
|
||||||
type: git
|
description: name of the master branch of the repository
|
||||||
|
workspaces:
|
||||||
|
- name: workspace
|
||||||
tasks:
|
tasks:
|
||||||
# - name: destroy-application #@TODO make it so that the delete can be skipped if error
|
- name: clone-master
|
||||||
# taskRef:
|
taskRef:
|
||||||
# name: destroy-application
|
name: git-clone
|
||||||
# resources:
|
workspaces:
|
||||||
# inputs:
|
- name: output
|
||||||
# - name: git-source
|
workspace: workspace
|
||||||
# resource: git-master
|
params:
|
||||||
|
- name: url
|
||||||
|
value: $(inputs.params.git-url)
|
||||||
|
- name: revision
|
||||||
|
value: $(inputs.params.master-branch)
|
||||||
- name: build-and-push-a
|
- name: build-and-push-a
|
||||||
taskRef:
|
taskRef:
|
||||||
name: build-and-push
|
name: build-and-push
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: workspace
|
||||||
params:
|
params:
|
||||||
- name: context
|
- name: context
|
||||||
value: "serverA"
|
value: "server-a"
|
||||||
- name: image-name
|
- name: image-name
|
||||||
value: "server-a"
|
value: "server-a"
|
||||||
- name: version
|
- name: version
|
||||||
value: "master"
|
value: "$(inputs.params.master-branch)"
|
||||||
resources:
|
|
||||||
inputs:
|
|
||||||
- name: git-source
|
|
||||||
resource: git-master
|
|
||||||
- name: build-and-push-b-stable
|
- name: build-and-push-b-stable
|
||||||
taskRef:
|
taskRef:
|
||||||
name: build-and-push
|
name: build-and-push
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: workspace
|
||||||
params:
|
params:
|
||||||
- name: context
|
- name: context
|
||||||
value: "serverB"
|
value: "server-b"
|
||||||
- name: image-name
|
- name: image-name
|
||||||
value: "server-b"
|
value: "server-b"
|
||||||
- name: version
|
- name: version
|
||||||
value: "master"
|
value: "$(inputs.params.master-branch)"
|
||||||
resources:
|
|
||||||
inputs:
|
|
||||||
- name: git-source
|
|
||||||
resource: git-master
|
|
||||||
- name: build-and-push-b-experimental
|
|
||||||
taskRef:
|
|
||||||
name: build-and-push
|
|
||||||
params:
|
|
||||||
- name: context
|
|
||||||
value: "serverB"
|
|
||||||
- name: image-name
|
|
||||||
value: "server-b"
|
|
||||||
- name: version
|
|
||||||
value: "experimental"
|
|
||||||
resources:
|
|
||||||
inputs:
|
|
||||||
- name: git-source
|
|
||||||
resource: git-experimental
|
|
||||||
- name: build-and-push-d
|
- name: build-and-push-d
|
||||||
taskRef:
|
taskRef:
|
||||||
name: build-and-push
|
name: build-and-push
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: workspace
|
||||||
params:
|
params:
|
||||||
- name: context
|
- name: context
|
||||||
value: "serverD"
|
value: "server-d"
|
||||||
- name: image-name
|
- name: image-name
|
||||||
value: "server-d"
|
value: "server-d"
|
||||||
- name: version
|
- name: version
|
||||||
value: "master"
|
value: "$(inputs.params.master-branch)"
|
||||||
resources:
|
- name: clone-experimental-branch
|
||||||
inputs:
|
|
||||||
- name: git-source
|
|
||||||
resource: git-master
|
|
||||||
- name: deploy-application #@TODO make it so that the delete can be skipped if error
|
|
||||||
taskRef:
|
taskRef:
|
||||||
name: deploy-application
|
name: git-clone
|
||||||
|
workspaces:
|
||||||
|
- name: output
|
||||||
|
workspace: workspace
|
||||||
runAfter:
|
runAfter:
|
||||||
- build-and-push-d
|
|
||||||
- build-and-push-b-experimental
|
|
||||||
- build-and-push-a
|
- build-and-push-a
|
||||||
- build-and-push-b-stable
|
- build-and-push-b-stable
|
||||||
#- destroy-application
|
- build-and-push-d
|
||||||
resources:
|
params:
|
||||||
inputs:
|
- name: url
|
||||||
- name: git-source
|
value: $(inputs.params.git-url)
|
||||||
resource: git-master
|
- name: revision
|
||||||
# DO NOT FORGET TO SET REGCREDS FOR DOCKER
|
value: $(inputs.params.experimental-branch)
|
||||||
|
- name: build-and-push-b-experimental
|
||||||
|
taskRef:
|
||||||
|
name: build-and-push
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: workspace
|
||||||
|
runAfter:
|
||||||
|
- clone-experimental-branch
|
||||||
|
params:
|
||||||
|
- name: context
|
||||||
|
value: "server-b"
|
||||||
|
- name: image-name
|
||||||
|
value: "server-b"
|
||||||
|
- name: version
|
||||||
|
value: "$(inputs.params.experimental-branch)"
|
||||||
|
- name: deploy-infra
|
||||||
|
taskRef:
|
||||||
|
name: execute-yaml
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: workspace
|
||||||
|
runAfter:
|
||||||
|
- build-and-push-b-experimental
|
||||||
|
params:
|
||||||
|
- name: yaml-location
|
||||||
|
value: "infra.yaml"
|
||||||
|
- name: execute-yaml #@TODO make it so that the delete can be skipped if error
|
||||||
|
taskRef:
|
||||||
|
name: execute-yaml
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: workspace
|
||||||
|
runAfter:
|
||||||
|
- deploy-infra
|
||||||
|
@@ -19,6 +19,17 @@ spec:
|
|||||||
- name: source
|
- name: source
|
||||||
value: github
|
value: github
|
||||||
---
|
---
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
apiVersion: v1
|
||||||
|
metadata:
|
||||||
|
name: workspace-pvc
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteMany
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 500Mi
|
||||||
|
---
|
||||||
apiVersion: tekton.dev/v1alpha1
|
apiVersion: tekton.dev/v1alpha1
|
||||||
kind: TriggerTemplate
|
kind: TriggerTemplate
|
||||||
metadata:
|
metadata:
|
||||||
@@ -41,13 +52,11 @@ spec:
|
|||||||
serviceAccountName: service-acc
|
serviceAccountName: service-acc
|
||||||
pipelineRef:
|
pipelineRef:
|
||||||
name: application-pipeline #gebruik dit om de pipeline aan te passen naar andere versies, zolang ze zich in dezelfde #namespace bevinden kunnen we deze pipeline hergebruiken om deployments op de cluster uit te voeren. service-mesh agnostisch.
|
name: application-pipeline #gebruik dit om de pipeline aan te passen naar andere versies, zolang ze zich in dezelfde #namespace bevinden kunnen we deze pipeline hergebruiken om deployments op de cluster uit te voeren. service-mesh agnostisch.
|
||||||
resources:
|
params:
|
||||||
- name: git-master
|
- name: git-url
|
||||||
resourceRef:
|
value: $(inputs.params.gitrepositoryurl)
|
||||||
name: git-master
|
- name: branch
|
||||||
- name: git-experimental
|
value: $(inputs.params.gitrevision)
|
||||||
resourceRef:
|
|
||||||
name: git-experimental
|
|
||||||
---
|
---
|
||||||
kind: ClusterRole
|
kind: ClusterRole
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
Reference in New Issue
Block a user