Skip to content

Commit

Permalink
Merge pull request #71 from CSCI-GA-2820-FA23-001/build_deploy
Browse files Browse the repository at this point in the history
add build image and deploy
  • Loading branch information
haofrank authored Dec 5, 2023
2 parents be792dc + 18b1334 commit 379de76
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 29 deletions.
83 changes: 62 additions & 21 deletions .tekton/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
creationTimestamp: '2023-12-03T20:32:31Z'
generation: 2
managedFields:
- apiVersion: tekton.dev/v1
fieldsType: FieldsV1
fieldsV1:
'f:spec':
.: {}
'f:finally': {}
'f:params': {}
'f:tasks': {}
'f:workspaces': {}
manager: Mozilla
operation: Update
time: '2023-12-03T21:55:43Z'
name: cd-pipeline
# namespace: devops-products
resourceVersion: '1583706109'
uid: 6ffec68d-1efc-4ae2-9811-9815aae271fb
spec:
workspaces:
- name: pipeline-workspace

params:
- description: The URL to the git repo
name: GIT_REPO
Expand All @@ -29,6 +15,16 @@ spec:
description: The reference (branch or ref)
name: GIT_REF
type: string
- default: products
description: Name of the application
name: APP_NAME
type: string
- default: >-
image-registry.openshift-image-registry.svc:5000/$(context.pipelineRun.namespace)/$(params.APP_NAME):latest
description: The name of the image to build
name: IMAGE_NAME
type: string
tasks:
- name: git-clone
params:
Expand Down Expand Up @@ -71,7 +67,52 @@ spec:
workspaces:
- name: output
workspace: pipeline-workspace
workspaces:
- name: pipeline-workspace
optional: false
finally: []

- name: buildah
params:
- name: IMAGE
value: $(params.IMAGE_NAME)
- name: BUILDER_IMAGE
value: >-
registry.redhat.io/rhel8/buildah@sha256:00795fafdab9bbaa22cd29d1faa1a01e604e4884a2c935c1bf8e3d1f0ad1c084
- name: STORAGE_DRIVER
value: vfs
- name: DOCKERFILE
value: ./k8s/Dockerfile
- name: CONTEXT
value: .
- name: TLSVERIFY
value: 'true'
- name: FORMAT
value: oci
- name: BUILD_EXTRA_ARGS
value: ''
- name: PUSH_EXTRA_ARGS
value: ''
- name: SKIP_PUSH
value: 'false'
runAfter:
- git-clone
taskRef:
kind: ClusterTask
name: buildah
workspaces:
- name: source
workspace: pipeline-workspace

- name: deploy-image
params:
- name: old_image_name
value: 'cluster-registry:32000/products:latest'
- name: image_name
value: $(params.IMAGE_NAME)
- name: manifest_dir
value: k8s
runAfter:
- buildah
taskRef:
kind: Task
name: deploy-image
workspaces:
- name: source
workspace: pipeline-workspace
24 changes: 16 additions & 8 deletions k8s/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ metadata:
labels:
app: products
spec:
replicas: 1
replicas: 2
selector:
matchLabels:
app: products
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
template:
metadata:
labels:
Expand All @@ -17,16 +22,19 @@ spec:
restartPolicy: Always
containers:
- name: products
image: docker.io/gorgeous/devops-23fall-products:20231127205915
# This image used in RedHat OpenShift
image: cluster-registry:32000/products:latest
# If you don't use ./tekton, use this image in other k8s
# image: docker.io/gorgeous/devops-23fall-products:20231127205915
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8000
- containerPort: 8000
env:
- name: DATABASE_URI
valueFrom:
secretKeyRef:
name: postgres-secret
key: database_uri
- name: DATABASE_URI
valueFrom:
secretKeyRef:
name: postgres-secret
key: database_uri
readinessProbe:
initialDelaySeconds: 5
periodSeconds: 20
Expand Down
6 changes: 6 additions & 0 deletions k8s/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@ green==3.4.3
factory-boy==3.2.1
coverage==7.1.0

# Behavior Driven Development
behave==1.2.6
selenium==4.10.0
compare==0.2b0
requests==2.31.0

# Utilities
httpie==3.2.1

0 comments on commit 379de76

Please sign in to comment.