Added sample application and pipeline.

This commit is contained in:
2023-07-30 22:18:21 +12:00
parent 489a1c8ced
commit cd4ba6e532
7 changed files with 233 additions and 5 deletions

1
2023-07-31-acs-workflows/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.env

View File

@ -32,7 +32,7 @@ For this demonstration we will be using [[https://developers.redhat.com/products
The first step to prepare the demo is to install the dev spaces operator so our cluster will be able to create cloud based development environments. We can install the operator programmatically by creating a ~subscription~ resource: The first step to prepare the demo is to install the dev spaces operator so our cluster will be able to create cloud based development environments. We can install the operator programmatically by creating a ~subscription~ resource:
#+begin_src bash :results silent #+begin_src bash :results silent
cat << EOF | oc apply -f - cat << EOF | oc apply --filename -
apiVersion: operators.coreos.com/v1alpha1 apiVersion: operators.coreos.com/v1alpha1
kind: Subscription kind: Subscription
metadata: metadata:
@ -55,7 +55,7 @@ Once the operator is installed we can create a devspaces controller instance, th
Once again we can do this programmatically by creating a ~checluster~ resource: Once again we can do this programmatically by creating a ~checluster~ resource:
#+begin_src bash :results silent #+begin_src bash :results silent
cat << EOF | oc apply -f - cat << EOF | oc apply --filename -
apiVersion: org.eclipse.che/v2 apiVersion: org.eclipse.che/v2
kind: CheCluster kind: CheCluster
metadata: metadata:
@ -106,7 +106,8 @@ EOF
Once the dev workspace operator and controller are ready we can create our individual developer workspace. Once the dev workspace operator and controller are ready we can create our individual developer workspace.
#+begin_src bash :results silent #+begin_src bash :results silent
cat << EOF | oc apply -f - oc new-project opentlc-mgr-devspaces
cat << EOF | oc apply --filename -
kind: DevWorkspace kind: DevWorkspace
apiVersion: workspace.devfile.io/v1alpha2 apiVersion: workspace.devfile.io/v1alpha2
metadata: metadata:
@ -145,4 +146,22 @@ EOF
** Deploy sample application ** Deploy sample application
In order to showcase incorporating ~roxctl~ into developer workflows we need a sample application to tinker with. In order to showcase incorporating ~roxctl~ into developer workflows we need a sample application to tinker with. For our purposes included in a subdirectory here is a small version of the classic kubernetes guestbook app.
We can deploy the application to our OpenShift cluster using the collection of yaml manifests in ~manifests/~ subdirectory. These will create a new ~deployment~, ~imagestream~, ~pipeline~ that in conjunction will deploy our application. We then trigger the deployment with the included ~pipelinerun~ resource.
The pipeline we run does rely on a secret containing our ~roxctl~ credentials so let's create that now as well.
#+begin_src bash :results silent
export $(cat .env)
oc new-project guestbook
oc create secret generic roxsecrets \
--from-literal=rox_api_token="${rox_api_token}" \
--from-literal=rox_central_endpoint="${rox_central_endpoint}" \
--dry-run=client --output=yaml \
| oc apply --filename -
oc apply --filename guestbook/manifests
#+end_src

View File

@ -4,7 +4,7 @@ COPY go.mod /guestbook/
COPY go.sum /guestbook/ COPY go.sum /guestbook/
RUN cd /guestbook && go build RUN cd /guestbook && go build
FROM docker.io/ubuntu:latest FROM docker.io/ubuntu:jammy-20230522
COPY --from=builder /guestbook/guestbook /app/guestbook COPY --from=builder /guestbook/guestbook /app/guestbook

View File

@ -0,0 +1,51 @@
---
kind: Deployment
apiVersion: apps/v1
metadata:
annotations:
alpha.image.policy.openshift.io/resolve-names: '*'
app.openshift.io/route-disabled: 'false'
app.openshift.io/vcs-ref: main
app.openshift.io/vcs-uri: 'https://github.com/jmhbnz/talks.git'
deployment.kubernetes.io/revision: '1'
image.openshift.io/triggers: >-
[{"from":{"kind":"ImageStreamTag","name":"guestbook:latest","namespace":"guestbook"},"fieldPath":"spec.template.spec.containers[?(@.name==\"guestbook\")].image","pause":"false"}]
openshift.io/generated-by: OpenShiftWebConsole
name: guestbook
namespace: guestbook
labels:
app.kubernetes.io/component: guestbook
app.kubernetes.io/instance: guestbook
app.kubernetes.io/name: guestbook
app.kubernetes.io/part-of: guestbook
spec:
replicas: 1
selector:
matchLabels:
app: guestbook
template:
metadata:
creationTimestamp: null
labels:
app: guestbook
deployment: guestbook
spec:
containers:
- name: guestbook
image: image-registry.openshift-image-registry.svc:5000/guestbook/guestbook:latest
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: Always
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
securityContext: {}
schedulerName: default-scheduler
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 25%
maxSurge: 25%
revisionHistoryLimit: 10
progressDeadlineSeconds: 600

View File

@ -0,0 +1,17 @@
---
kind: ImageStream
apiVersion: image.openshift.io/v1
metadata:
annotations:
app.openshift.io/vcs-ref: main
app.openshift.io/vcs-uri: 'https://github.com/jmhbnz/talks.git'
name: guestbook
namespace: guestbook
labels:
app.kubernetes.io/component: guestbook
app.kubernetes.io/instance: guestbook
app.kubernetes.io/name: guestbook
app.kubernetes.io/part-of: guestbook
spec:
lookupPolicy:
local: false

View File

@ -0,0 +1,97 @@
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
labels:
app.kubernetes.io/instance: guestbook
app.kubernetes.io/name: guestbook
operator.tekton.dev/operand-name: openshift-pipelines-addons
pipeline.openshift.io/strategy: docker
pipeline.openshift.io/type: kubernetes
name: guestbook
namespace: guestbook
spec:
params:
- default: guestbook
name: APP_NAME
type: string
- default: 'https://github.com/jmhbnz/talks.git'
name: GIT_REPO
type: string
- default: main
name: GIT_REVISION
type: string
- default: 'image-registry.openshift-image-registry.svc:5000/guestbook/guestbook'
name: IMAGE_NAME
type: string
- default: 2023-07-31-acs-workflows/guestbook
name: PATH_CONTEXT
type: string
tasks:
- name: fetch-repository
params:
- name: url
value: $(params.GIT_REPO)
- name: revision
value: $(params.GIT_REVISION)
- name: subdirectory
value: ''
- name: deleteExisting
value: 'true'
taskRef:
kind: ClusterTask
name: git-clone
workspaces:
- name: output
workspace: workspace
- name: build
params:
- name: IMAGE
value: $(params.IMAGE_NAME)
- name: TLSVERIFY
value: 'false'
- name: CONTEXT
value: $(params.PATH_CONTEXT)
runAfter:
- fetch-repository
taskRef:
kind: ClusterTask
name: buildah
workspaces:
- name: source
workspace: workspace
- name: image-scan
params:
- name: image
value: image-registry.openshift-image-registry.svc:5000/guestbook/guestbook
- name: rox_api_token
value: roxsecrets
- name: rox_central_endpoint
value: roxsecrets
- name: output_format
value: pretty
taskRef:
kind: ClusterTask
name: rox-image-scan
- name: image-check
params:
- name: image
value: image-registry.openshift-image-registry.svc:5000/guestbook/guestbook
- name: rox_api_token
value: roxsecrets
- name: rox_central_endpoint
value: roxsecrets
taskRef:
kind: ClusterTask
name: rox-image-check
- name: deploy
params:
- name: SCRIPT
value: oc rollout status deploy/$(params.APP_NAME)
runAfter:
- build
taskRef:
kind: ClusterTask
name: openshift-client
workspaces:
- name: workspace

View File

@ -0,0 +1,43 @@
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: guestbook-initial
namespace: guestbook
labels:
app.kubernetes.io/instance: guestbook
app.kubernetes.io/name: guestbook
operator.tekton.dev/operand-name: openshift-pipelines-addons
pipeline.openshift.io/strategy: docker
pipeline.openshift.io/type: kubernetes
tekton.dev/pipeline: guestbook
spec:
params:
- name: APP_NAME
value: guestbook
- name: GIT_REPO
value: 'https://github.com/jmhbnz/talks.git'
- name: GIT_REVISION
value: main
- name: IMAGE_NAME
value: 'image-registry.openshift-image-registry.svc:5000/guestbook/guestbook'
- name: PATH_CONTEXT
value: 2023-07-31-acs-workflows/guestbook
pipelineRef:
name: guestbook
serviceAccountName: pipeline
timeout: 1h0m0s
workspaces:
- name: workspace
volumeClaimTemplate:
metadata:
creationTimestamp: null
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: gp3-csi
volumeMode: Filesystem
status: {}