Track efforts to get trigger working.

This commit is contained in:
James Pace 2022-08-27 21:53:10 -04:00
parent d63cbd3327
commit f967c90da8
7 changed files with 183 additions and 0 deletions

22
ambassador/listener.yaml Normal file
View File

@ -0,0 +1,22 @@
---
apiVersion: getambassador.io/v3alpha1
kind: Host
metadata:
name: tekton-host
spec:
hostname: "tekton.internal.jpace121.net"
requestPolicy:
insecure:
action: Route
---
apiVersion: getambassador.io/v3alpha1
kind: Listener
metadata:
name: http-listener
spec:
port: 8080
protocol: HTTP
securityModel: INSECURE
hostBinding:
namespace:
from: SELF

7
ambassador/mapping.yaml Normal file
View File

@ -0,0 +1,7 @@
apiVersion: getambassador.io/v3alpha1
kind: Mapping
metadata:
name: test-listener-mapping
spec:
prefix: /test-event/
service: el-test-listener.default.svc.cluster.local:8080

View File

@ -37,6 +37,7 @@ kubectl config set-context j7s-dev --namespace=j7s-dev \
--cluster=j7s-dev \ --cluster=j7s-dev \
--user=default --user=default
``` ```
I'm not sure the above command works...
Stuff I installed from tkn. Stuff I installed from tkn.
``` ```
@ -45,4 +46,26 @@ tkn hub install task ansible-runner
tkn hub install task git-batch-merge tkn hub install task git-batch-merge
``` ```
Triggers:
Install:
kubectl apply --filename https://storage.googleapis.com/tekton-releases/triggers/latest/release.yaml
kubectl apply --filename https://storage.googleapis.com/tekton-releases/triggers/latest/interceptors.yaml
Amabassador: (for knative)
Start with these instruction to disable traefik.
https://www.suse.com/c/rancher_blog/deploy-an-ingress-controller-on-k3s/
use `--disable=traefik` in systemd.
The equal is important...
Follow the instructions https://www.getambassador.io/docs/edge-stack/latest/topics/install/yaml-install/ to install ambassador.
I used the file in ./ambassador/listener.yaml to set up the listener.
I'm not sure why ambassdor is listening on 80 instead of 8080 given the
settings I applied, or why changing from 8080 to 80 in the seeting borks
it.

11
scripts/Dockerfile_flask Normal file
View File

@ -0,0 +1,11 @@
FROM docker.io/debian:bullseye-slim
RUN apt update -y && \
apt install -y python3-flask && \
mkdir /app
COPY test.py /app/test.py
WORKDIR /app
ENV FLASK_APP=test
CMD ["flask", "run", "--host", "0.0.0.0"]

22
scripts/test.py Normal file
View File

@ -0,0 +1,22 @@
from flask import Flask
from flask import request
import logging
app = Flask(__name__)
logger = logging.getLogger('j7s-app')
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
logger.addHandler(handler)
@app.route("/", defaults={"path": ""}, methods = ['POST', 'GET'])
@app.route('/<path:path>', methods=['POST', 'GET'])
def root(path):
logger.info("Path")
logger.info(path)
logger.info("Headers:")
logger.info(request.headers)
logger.info("Body:")
logger.info(request.json)
return "<p>Hello</p>"

View File

@ -0,0 +1,31 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: tekton-bot
secrets:
- name: git-credentials
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: tekton-bot-eventlistener-binding
subjects:
- kind: ServiceAccount
name: tekton-bot
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: tekton-triggers-eventlistener-roles
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: tekton-bot-eventlistener-clusterbinding
subjects:
- kind: ServiceAccount
name: tekton-bot
namespace: default
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: tekton-triggers-eventlistener-clusterroles

View File

@ -0,0 +1,67 @@
---
apiVersion: triggers.tekton.dev/v1beta1
kind: EventListener
metadata:
name: test-listener
spec:
serviceAccountName: tekton-bot
triggers:
- name: test-trigger
bindings:
- ref: message-binding
template:
ref: pipeline-template
---
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerBinding
metadata:
name: pipeline-binding
spec:
params:
- name: gitrevision
value: $(body.patchSet.revision)
---
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerBinding
metadata:
name: message-binding
spec:
params:
- name: gitrepositoryurl
value: ssh://gerrit.internal.jpace121.net:29418/ci/test
---
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerTemplate
metadata:
name: pipeline-template
spec:
params:
- name: gitrevision
description: The git revision
default: main
- name: gitrepositoryurl
description: The git repository url
resourcetemplates:
- apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: test-run-
spec:
pipelineRef:
name: git-pipeline
params:
- name: repo-url
value: $(tt.params.gitrepositoryurl)
workspaces:
- name: shared-data
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
- name: git-credentials
secret:
secretName: git-credentials