mirror of
https://github.com/bvanroll/cicdTest.git
synced 2025-08-29 20:12:43 +00:00
help
This commit is contained in:
37
README.md
37
README.md
@@ -1 +1,36 @@
|
||||
# cicdTest
|
||||
# cicdTest
|
||||
|
||||
|
||||
## teamcity
|
||||
|
||||
voor teamcity was het opstellen van de server heel simpel aangezien dit via een docker container kan.
|
||||
Er moet wel een aparte agent opgesteld worden, maar dit kan ook via een docker container.
|
||||
|
||||
server:
|
||||
|
||||
docker run -it --name teamcity-server-instance \
|
||||
-v /Users/beppe/teamcity/data:/data/teamcity_server/datadir \
|
||||
-v /Users/beppe/teamcity/logs:/opt/teamcity/logs \
|
||||
-p 8080:8111 \
|
||||
jetbrains/teamcity-server
|
||||
|
||||
agent:
|
||||
|
||||
docker run -it -e SERVER_URL="localhost:8080" -v /Users/beppe/teamcity/agent/:/data/teamcity_agent/conf jetbrains/teamcity-agent
|
||||
|
||||
de reden dat we een agent nodig hebben is om docker images te builden en pushen.
|
||||
|
||||
|
||||
|
||||
|
||||
## tekton
|
||||
|
||||
https://developer.ibm.com/tutorials/deploy-a-hello-world-application-on-kubernetes-using-tekton-pipelines/
|
||||
|
||||
https://github.com/tektoncd/pipeline/blob/master/docs/tutorial.md
|
||||
|
||||
install tekton
|
||||
|
||||
kubectl apply --filename https://storage.googleapis.com/tekton-releases/latest/release.yaml
|
||||
|
||||
|
||||
|
54
deploy.yaml
54
deploy.yaml
@@ -0,0 +1,54 @@
|
||||
---
|
||||
kind: service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: server-check
|
||||
spec:
|
||||
selector:
|
||||
server: http
|
||||
ports:
|
||||
- name: http
|
||||
protocol: TCP
|
||||
port: 5000
|
||||
---
|
||||
kind: service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: expose-server
|
||||
spec:
|
||||
selector:
|
||||
expose: true
|
||||
ports:
|
||||
- name: http
|
||||
protocol: TCP
|
||||
targetPort: 5000
|
||||
port: 5000
|
||||
nodePort: 30036
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: server-a
|
||||
labels:
|
||||
server: http
|
||||
expose: true
|
||||
spec:
|
||||
containers:
|
||||
- name: front-end
|
||||
image: IMAGE-A
|
||||
ports:
|
||||
- containerPort: 5000
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: server-b
|
||||
labels:
|
||||
server: http
|
||||
spec:
|
||||
containers:
|
||||
- name: front-end
|
||||
image: IMAGE-B
|
||||
ports:
|
||||
- containerPort: 5000
|
||||
|
||||
|
86
manifests/pipeline/pipeline.yaml
Normal file
86
manifests/pipeline/pipeline.yaml
Normal file
@@ -0,0 +1,86 @@
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: Pipeline
|
||||
metadata:
|
||||
name: application-pipeline
|
||||
spec:
|
||||
resources:
|
||||
- name: git-source
|
||||
type: git
|
||||
params:
|
||||
- name: pathToYamlFile
|
||||
description: path to deploy.yaml for final application deploy
|
||||
default: config.yaml
|
||||
- name: pathToContext
|
||||
description: The path to the build context, used by Kaniko - within the workspace
|
||||
default: .
|
||||
- name: imageUrl-a
|
||||
description: Url of image repository a
|
||||
default: deploy_target
|
||||
- name: imageTag-a
|
||||
description: Tag to apply to the built image a
|
||||
default: latest
|
||||
- name: pathToContext-a
|
||||
description: The path to the build context, used by Kaniko - within the workspace
|
||||
default: .
|
||||
- name: imageUrl-b
|
||||
description: Url of image repository
|
||||
default: deploy_target
|
||||
- name: imageTag-b
|
||||
description: Tag to apply to the built image
|
||||
default: latest
|
||||
- name: pathToContext-b
|
||||
description: The path to the build context, used by Kaniko - within the workspace
|
||||
default: .
|
||||
tasks:
|
||||
- name: build-and-push-a
|
||||
taskRef:
|
||||
name: build-and-push
|
||||
params:
|
||||
- name: pathToContext
|
||||
value: "$(params.pathToContext-a)"
|
||||
- name: imageUrl
|
||||
value: "$(params.imageUrl-a)"
|
||||
- name: imageTag
|
||||
value: "$(params.imageTag-a)"
|
||||
resources:
|
||||
inputs:
|
||||
- name: git-source
|
||||
resource: git-source
|
||||
- name: build-and-push-b
|
||||
taskRef:
|
||||
name: build-and-push
|
||||
runAfter:
|
||||
- build-and-push-a
|
||||
params:
|
||||
- name: pathToContext
|
||||
value: "$(params.pathToContext-b)"
|
||||
- name: imageUrl
|
||||
value: "$(params.imageUrl-b)"
|
||||
- name: imageTag
|
||||
value: "$(params.imageTag-b)"
|
||||
resources:
|
||||
inputs:
|
||||
- name: git-source
|
||||
resource: git-source
|
||||
- name: deploy-application
|
||||
taskRef:
|
||||
name: deploy-application
|
||||
runAfter:
|
||||
- build-and-push-b
|
||||
params:
|
||||
- name: pathToContext
|
||||
value: "$(params.pathToContext)"
|
||||
- name: pathToYamlFile
|
||||
value: "$(params.pathToYamlFile)"
|
||||
- name: imageUrl-a
|
||||
value: "$(params.imageUrl-a)"
|
||||
- name: imageTag-a
|
||||
value: "$(params.imageTag-a)"
|
||||
- name: imageUrl-b
|
||||
value: "$(params.imageUrl-b)"
|
||||
- name: imageTag-b
|
||||
value: "$(params.imageTag-b)"
|
||||
resources:
|
||||
inputs:
|
||||
- name: git-source
|
||||
resource: git-source
|
29
manifests/pipeline/pipelineRun.yaml
Normal file
29
manifests/pipeline/pipelineRun.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: PipelineRun
|
||||
metadata:
|
||||
name: application-pipeline-run
|
||||
spec:
|
||||
serviceAccountName: tutorial-service
|
||||
pipelineRef:
|
||||
name: application-pipeline
|
||||
resources:
|
||||
- name: git-source
|
||||
resourceRef:
|
||||
name: git
|
||||
params:
|
||||
- name: pathToYamlFile
|
||||
value: "deploy.yaml"
|
||||
- name: pathToContext
|
||||
value: "."
|
||||
- name: imageUrl-a
|
||||
value: "beppeserver-a"
|
||||
- name: imageTag-a
|
||||
value: "beppeserver-a-tag"
|
||||
- name: pathToContext-a
|
||||
value: "./serverA"
|
||||
- name: imageUrl-b
|
||||
value: "beppeserver-b"
|
||||
- name: imageTag-b
|
||||
value: "beppeserver-b-tag"
|
||||
- name: pathToContext-b
|
||||
value: "./serverB"
|
7
manifests/pipeline/serviceAcc.yaml
Normal file
7
manifests/pipeline/serviceAcc.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: tutorial-service
|
||||
secrets:
|
||||
- name: regcred
|
12
manifests/resources/git.yaml
Normal file
12
manifests/resources/git.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: PipelineResource
|
||||
metadata:
|
||||
name: git
|
||||
spec:
|
||||
type: git
|
||||
params:
|
||||
- name: revision
|
||||
value: master
|
||||
- name: url
|
||||
value: https://github.com/beppevanrolleghem/cicdTest
|
30
manifests/tasks/build-and-push.yaml
Normal file
30
manifests/tasks/build-and-push.yaml
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: build-and-push
|
||||
spec:
|
||||
inputs:
|
||||
resources:
|
||||
- name: git-source
|
||||
type: git
|
||||
params:
|
||||
- name: pathToContext
|
||||
description: The path to the build context, used by Kaniko - within the workspace
|
||||
default: .
|
||||
- name: pathToDockerfile
|
||||
description: The path to the dockerfile to build
|
||||
default: Dockerfile
|
||||
- name: imageUrl
|
||||
description: value should be like - us.icr.io/test_namespace/builtImageApp
|
||||
- name: imageTag
|
||||
description: Tag to apply to the built image
|
||||
steps:
|
||||
- name: build-and-push
|
||||
image: gcr.io/kaniko-project/executor
|
||||
command:
|
||||
- /kaniko/executor
|
||||
args:
|
||||
- "--dockerfile=$(inputs.params.pathToContext)/dockerfile"
|
||||
- "--destination=$(inputs.params.imageUrl):$(inputs.params.imageTag)"
|
||||
- "--context=$(inputs.resources.git-source.path)/$(inputs.params.pathToContext)/"
|
53
manifests/tasks/deploy-application.yaml
Normal file
53
manifests/tasks/deploy-application.yaml
Normal file
@@ -0,0 +1,53 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: deploy-application
|
||||
spec:
|
||||
inputs:
|
||||
resources:
|
||||
- name: git-source
|
||||
type: git
|
||||
params:
|
||||
- name: pathToContext
|
||||
description: The path to the build context, used by Kaniko - within the workspace
|
||||
default: .
|
||||
- name: pathToYamlFile
|
||||
description: The path to the yaml file to deploy within the git source
|
||||
default: deploy.yaml
|
||||
- name: imageUrl-a
|
||||
description: Url of image repository
|
||||
default: url
|
||||
- name: imageTag-a
|
||||
description: Tag of the images to be used.
|
||||
default: "latest"
|
||||
- name: imageUrl-b
|
||||
description: Url of image repository
|
||||
default: url
|
||||
- name: imageTag-b
|
||||
description: Tag of the images to be used.
|
||||
default: "latest"
|
||||
steps:
|
||||
- name: replace-imagea
|
||||
image: alpine
|
||||
command: ["sed"]
|
||||
args:
|
||||
- "-i"
|
||||
- "-e"
|
||||
- "s;IMAGE-A;$(inputs.params.imageUrl-a):$(inputs.params.imageTag-a);g"
|
||||
- "$(inputs.resources.git-source.path)/$(inputs.params.pathToContext)/$(inputs.params.pathToYamlFile)"
|
||||
- name: replace-imageb
|
||||
image: alpine
|
||||
command: ["sed"]
|
||||
args:
|
||||
- "-i"
|
||||
- "-e"
|
||||
- "s;IMAGE-b;$(inputs.params.imageUrl-b):$(inputs.params.imageTag-b);g"
|
||||
- "$(inputs.resources.git-source.path)/$(inputs.params.pathToContext)/$(inputs.params.pathToYamlFile)"
|
||||
- name: deploy-app
|
||||
image: lachlanevenson/k8s-kubectl
|
||||
command: ["kubectl"]
|
||||
args:
|
||||
- "apply"
|
||||
- "-f"
|
||||
- "$(inputs.resources.git-source.path)/$(inputs.params.pathToContext)/$(inputs.params.pathToYamlFile)"
|
@@ -3,7 +3,7 @@ import requests
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
URL = "http://service"
|
||||
URL = "http://service:5000"
|
||||
|
||||
|
||||
@app.route('/')
|
||||
|
@@ -7,4 +7,4 @@ run pip install -r requirements.txt
|
||||
expose 5000
|
||||
entrypoint [ "python" ]
|
||||
|
||||
cmd [ "app.py" ]
|
||||
cmd [ "__init__.py" ]
|
@@ -7,4 +7,4 @@ run pip install -r requirements.txt
|
||||
expose 5000
|
||||
entrypoint [ "python" ]
|
||||
|
||||
cmd [ "app.py" ]
|
||||
cmd [ "__init__.py" ]
|
Reference in New Issue
Block a user