From 40c6faf21c344b6c10165e66805fa8ec5e7f4366 Mon Sep 17 00:00:00 2001 From: beppe Date: Mon, 16 Mar 2020 11:14:14 +0100 Subject: [PATCH] housekeeping --- .DS_Store | Bin 8196 -> 10244 bytes manifests/.DS_Store | Bin 0 -> 8196 bytes manifests/Tekton/.DS_Store | Bin 0 -> 12292 bytes manifests/Tekton/pipeline/.DS_Store | Bin 0 -> 6148 bytes manifests/Tekton/pipeline/pipeline.yaml | 120 +++++++ manifests/Tekton/resources/.DS_Store | Bin 0 -> 6148 bytes .../resources/create-repo-webhook.yaml | 0 .../resources/create-webhook.yaml | 0 .../Tekton/resources/experimental-pvc.yaml | 12 + manifests/Tekton/resources/master-pvc.yaml | 12 + .../{ => Tekton}/resources/namespace.yaml | 0 manifests/Tekton/resources/secrets.yaml | 9 + manifests/Tekton/runs/.DS_Store | Bin 0 -> 6148 bytes manifests/Tekton/runs/pipeline/.DS_Store | Bin 0 -> 6148 bytes .../runs}/pipeline/pipelineRun.yaml | 0 .../Tekton/runs/task/create-repo-webhook.yaml | 28 ++ manifests/Tekton/service-accounts/.DS_Store | Bin 0 -> 6148 bytes .../cluster-role-binding.yaml | 2 +- .../Tekton/service-accounts/cluster-role.yaml | 43 +++ .../service-accounts}/service-account.yaml | 3 +- manifests/Tekton/tasks/build-and-push.yaml | 32 ++ manifests/Tekton/tasks/create-webhook.yaml | 51 +++ manifests/Tekton/tasks/execute-yaml.yaml | 24 ++ manifests/Tekton/tasks/git-clone.yaml | 72 ++++ manifests/Tekton/triggers/event-listener.yaml | 36 ++ .../Tekton/triggers/trigger-binding.yaml | 18 + .../Tekton/triggers/trigger-template.yaml | 35 ++ .../event-listener-debug.yaml} | 4 +- manifests/full-pipeline.yaml | 309 ------------------ manifests/github-event-listener.yaml | 141 -------- manifests/github-webhook-setup.yaml | 261 --------------- manifests/pipeline-run.yaml | 16 - manifests/pipeline/pipeline.yaml | 83 ----- manifests/resources/cluster-role.yaml | 29 -- manifests/resources/git.yaml | 26 -- manifests/tasks/build-and-push.yaml | 31 -- manifests/tasks/deploy-application.yaml | 26 -- manifests/test.yaml | 19 -- manifests/triggers/event-listener.yaml | 12 - manifests/triggers/trigger-binding.yaml | 18 - manifests/triggers/trigger-template.yaml | 30 -- 41 files changed, 496 insertions(+), 1006 deletions(-) create mode 100644 manifests/.DS_Store create mode 100644 manifests/Tekton/.DS_Store create mode 100644 manifests/Tekton/pipeline/.DS_Store create mode 100644 manifests/Tekton/pipeline/pipeline.yaml create mode 100644 manifests/Tekton/resources/.DS_Store rename manifests/{ => Tekton}/resources/create-repo-webhook.yaml (100%) rename manifests/{ => Tekton}/resources/create-webhook.yaml (100%) create mode 100644 manifests/Tekton/resources/experimental-pvc.yaml create mode 100644 manifests/Tekton/resources/master-pvc.yaml rename manifests/{ => Tekton}/resources/namespace.yaml (100%) create mode 100644 manifests/Tekton/resources/secrets.yaml create mode 100644 manifests/Tekton/runs/.DS_Store create mode 100644 manifests/Tekton/runs/pipeline/.DS_Store rename manifests/{ => Tekton/runs}/pipeline/pipelineRun.yaml (100%) create mode 100644 manifests/Tekton/runs/task/create-repo-webhook.yaml create mode 100644 manifests/Tekton/service-accounts/.DS_Store rename manifests/{resources => Tekton/service-accounts}/cluster-role-binding.yaml (85%) create mode 100644 manifests/Tekton/service-accounts/cluster-role.yaml rename manifests/{resources => Tekton/service-accounts}/service-account.yaml (56%) create mode 100644 manifests/Tekton/tasks/build-and-push.yaml create mode 100644 manifests/Tekton/tasks/create-webhook.yaml create mode 100644 manifests/Tekton/tasks/execute-yaml.yaml create mode 100644 manifests/Tekton/tasks/git-clone.yaml create mode 100644 manifests/Tekton/triggers/event-listener.yaml create mode 100644 manifests/Tekton/triggers/trigger-binding.yaml create mode 100644 manifests/Tekton/triggers/trigger-template.yaml rename manifests/{demo.yaml => Utilities/event-listener-debug.yaml} (87%) delete mode 100644 manifests/full-pipeline.yaml delete mode 100644 manifests/github-event-listener.yaml delete mode 100644 manifests/github-webhook-setup.yaml delete mode 100644 manifests/pipeline-run.yaml delete mode 100644 manifests/pipeline/pipeline.yaml delete mode 100644 manifests/resources/cluster-role.yaml delete mode 100644 manifests/resources/git.yaml delete mode 100644 manifests/tasks/build-and-push.yaml delete mode 100644 manifests/tasks/deploy-application.yaml delete mode 100644 manifests/test.yaml delete mode 100644 manifests/triggers/event-listener.yaml delete mode 100644 manifests/triggers/trigger-binding.yaml delete mode 100644 manifests/triggers/trigger-template.yaml diff --git a/.DS_Store b/.DS_Store index 132b9cda4dbf73af9f0ed01ee8d9646dd623c747..8ba54e7d372e10bd6bcc0eb056e23da04ae339f1 100644 GIT binary patch literal 10244 zcmeHN&u<$=6n>L9be%NGrcFoP^NbAuB(tWb03-kq@S##Xh*?CU?eu9&U4BgxCBgn+6jRx}RVue>@(RuXXMi)n z8Q=_X2L3M$V9cgT=<_7cIRl&l&Onm^>K`P0s7(8^?n&l4Fk?pmlrgMk3Ckiapp<-> z_GR6Z*n)|8T~T^niGRc(UU#gQe7&?U>z?$w1Mv?Z#J5cR6AEG0aeRrX14(<5=bQn~ zKsy8U>>h(Bpa?p+q4WFbGw%i4O4iJbVps~+312Dw$LBQ?prTUDZ(K$|c=Yt@VtxW~vSwC+jr`LR^UF#6-24N={8pNU7<`+Jsb{ zno3ScQ>mwGwYV_)Nb2^_AMIx9DWhcl$mb2EF%Yej7^>a}6$8M6;f+_*9U) z4Jv*S#ReJi-oAtV1B2qwp~FMNLn9+24~~u;Nj#LuiH8+Af1_yAX`QnS%gz{U+Dg&Z z)ofYL>t=Du)n0b9`lgl>5A9IBsHxXlRSO$s)ERD7u;HGwHO*w>%@qoc<}T&LK__op zhB0qBx~p5}a-enjih~O@>uRN0vtXgc3NFZ8nW{O9n(d%$>%X)t+qP^LwamsUNsEuA=e@c( z2Jmq>3opVV+<;AZ3*LcG;8WO!`|un5MGg>=93$golAI=I$n#{DTp;u0C34y8-ql$1 zqYV?DBr7N*7B##J>u*PE1@~a>-9*B7S`p&~cVK7D(EcNDQkW6rRkF5eSY{Dh>C6P& zl^WPkVfl%j4zIfwr4vNIb@%eOZwxRG(l%BQdndgRa!8`dHe5=WSF#aD5bkD<8x)zP&3h)N6U$PI`O5rG{~JFGS!{gSh5?+!YtdEQp3F*ny$!4UOeCiZNinx$C{_MqTYp>nB zb^FfyAAGp=1?$xc7DL{9Gyjr~*-lG1ShTSgUeCurjvgeqqPgQ+jo2PxF1V(hHN&e~ zr}KyyZ--xrF^^(GC4~Fb>-VvDvn_}=`Nz+VuTO#Y*5@v&J%lXd`+JIyC(Zz8fHS}u z*q01+d#ELP|9^h>-~adJ+&E~?0B2xt43OANb|!t I_V4-sZ?YLLdjJ3c delta 551 zcmZn(XmOBWU|?W$DortDU;r^WfEYvza8FDWo2aMAsJk&>H$S89WF7&@Sdp}9pcD&( z9z!}qCPPVXzKcszPJR+d+l@cl;=i#UazvF+!7E>oVHlj8pIZRb!@wXmxk)XS1#;4n z>|$`OocvcrV)APdE;bpNG@y->e~YNVn5v>`ObiT@^F>|Qw$*|qABu`iJ}=6H;CfCz zBqlQ1PK=jLY93fcpqLVZDK@!ZEQHN*D_BNQTx{}xF&+fhlTl}Kw73G>=ZQByePN&6 zD6WKHif!I6-p9zHpqdU2g~{iEnzJQ&*dPLvYbER0LKI6t?q!scf-x1PP6{%E!;nFO k8%Vo?VsB&Ocjn3bDuEn~kT_+S9M3a#^8@i*(oH`G03g(w$^ZZW diff --git a/manifests/.DS_Store b/manifests/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..c965ddf7f6bc7e6f3b55c1e7e22acb7879c1f6bc GIT binary patch literal 8196 zcmeHM%}*0S6n_H<+ah%N5-=V%5)%_R(1ch$5K5_0LX=7oLBO(Yhq7V2)9h}kfSCRZ zdhnnz@$AKeM-L{RjQ@Zq=$T@lB6=Xc zDe*%LBFwQ}F9ySKw4P}l~y zCVu~vE|`Ynj*ovPEv;>5+B*~_s06!$>&Y!vO1ipRbYi-_%6}zvcPs7J7a21T>w0?0 zprw@BKf^3nH!Ny<#zvN+%Gy1{%Cb_76|Jn}^^+70iV{!)DRp>%KRh0ZjA`L(69;43 zek3wJrbWV64-Nv#;HB{7>_&cfZ~xK3w#D6(JsAi!rYFBAwcKllk^0uVkxdr#jA7-L zUHZ^X8hbRQ_SUE_(CmXF(c*3ab^4D4UUxTaN-eLy`OQs-y2~jwyX&T&rsljAW3J2c%SMJ- zV&);QTl|@@DerP*>boFxBsy2ATox4-MnnbAkt$iV^gIoWL=!?5z?b?cOv5c$!tJ#O zPv9lIfp_o`zQ8y5K{|*^E|O6)K_t8}uH?qm%f>Ty?VS!le?s~t|wzh3eku0el!cI0-y);#8X z;+WW=zZw_B>B-cDfmR_O;_?6W=J)?itfg2oAQ?Cf43M^XG9JT~RL)zqi{i1ihIs=s zPh77o&@;ip3&#2BKKP213>;;?D}AsQrGsxSyub=@GaDu}^RNJvYvwl~fy>m6%% zosfhe-#ByS>JO#Hy>~IxAWf2 z001er>p6gz06@XWsCE`$Oa;)-;Ga-n76AN8}A z_glzwp`XF4d&@OVhu62XwdI-q>V}r_YA&_yGW9IqqRv{VbnT9}P4`N^*(^C*6kFW2 z%)O-+WAj!_*F&0+UtKd?*KitUasRGuR84!yDN^63%~h*L9ntd)uNME7U6WNgf8(K; z)%n8hZh~P6g9h^=f#}i5vSTz&b-qv*c`736D%^y3U7GQX=C9zLAp<}e&W$~MI@CPkQ#U@H4uD6l-PRz zRO&(wT53RQAgTfOeb6y7S_o)IQ2yz_2QwjAIWr-7z%=>+JWmg3A)p;WxhTqTQKUkY z1TF><;+U^9cBF-Xb_5mTK!iAupk)$xD1^6;ayn-RQV>)=r3R!1k{Y;-S>q7+es&{Q zsnKRju;o4rmo@3)V&K;+)7kvJA2L7RjF#62mbbRUb#phU*Y0k`b!_T1us#NF4LmTh zPrG124O6dxfwTscd#FBm)jhAf$M9>{NBx}y9;z~>OifSSt)Tx`@eRN26%BWt{VN;( zb~Q*ZQ)>6pMs)>UIdnO1QO7qd$8@={RX364&IguLr+Y=_*Lu93iYQPNRZ%yzxx>R; zHlJV6bFW`JTF?*k`Rsz8&%JhZq$(F*$XzdOHunz>KRNpJ3mh2+5`4fQBmVcEUt;Rm zk@t63q<21q-uX$UI10i`Y<)ZSwFrarjYr>*9|bs1AlC=&zmbcAS;sCO-^UopC%{Ko zd${{Cx^NDSQ37|Ux7F|k4^3tiqLZ&iOT%C+{q~bqQTa+4l5f&J?9w?>02Y#uK}kU< zxwuv~@W@b!TB~n6&Tz z6>MfDUXQS$K8P>Xeu(ueWqq*MkJ9v-XA4d&MFg4-bKX(5AChp)p z=KddNk`Ji?se#ed02yDbEV7Sv_h>3UOm^0;W8B2Z0^{ol+7rP9KZ-}nkK&Q?eH3J4 p{Dpva1jQT-|NA8XdCl}cx@L-#m$F{V^`9LaFFzsY$%EJbe*l+qPG0~3 literal 0 HcmV?d00001 diff --git a/manifests/Tekton/pipeline/.DS_Store b/manifests/Tekton/pipeline/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0}G-5-b9i-F7G&wmX~MEfs1_ zzk*kdpTUDi6HPoBzW^uWN6@P`-~6e7#pp?h*_X`x-n@BlX5Mc*GaZBw&NZrOgj9r( z0)=5D2Gt3|`dR6bK4}>M#C!}JS;#@eZ2E4GcW4M12pKqQ46wbcAQ$$niwHWhe@&a3 z(D%u7ZOac*sRP{CA31k^Kv7~!Y$&#&Z_}n87(v6&8QvOe6^&rql=?EI_D|g~S1i&j zt78k)2@K029uKyv1YFi1T27TVbF|@9eLjvZIus?UM9b=AtCdb=GSgc6)=Ya^Yh^O2 zX)Tk!*=|Rb@$2c?!e)JMzxA~J?1i8f!%4&?F0l(QLFviVs_eQVQ~aiz=@(V)<{FI+ zUKqLSZR+Lh23f0lR#kV6isjTw0eKSW z);=k#Bfq#lAl1i*rsX{se8vt9e7HLvAr2pJX=}?TL8+|9{fb9zyGVU2u&A?oq<3}Q z2mT8IsTZ6r3N!8k-%BoY^H+%H1NOw1Rt?WHoEpjPZP?J2hgMijcR)soZ<#9eN zG>aZ#Lni0G2{x12#jbKgC@M+{1xQx$vSZXqG?^_5TNH?&Li6YzT0uK#A3aB}&};M- zeMFzpSM(hZU=?4(Q+Ni?;yHX57w{r3;`{iK2=D8D(ktC51mZQoo=KK^0;q_OI>`d5DL_Mhk6)jh|iP7UVi<|EQLwOTGi89cQWgcFAh zgbbWj2H5$aL1CDc*b&H&4ygDO05Ae(E}*MS0n{XBC3XZt4+s{afFcybK`!h(9PFBG zXC-z7ig1MG;{(f?v3#Lm5st9N-4V_T4C|1Akb&b2^oyp-?*H4rfBzp33R@uqAp`#v z12~e`^EpUK-mN{!vAb4-vI&I=^XmxYAyCQdm@Dimo`Avy`ZT5hW+iq6f(0b}Bfx10 KtB`?z%D@jAp7M+U literal 0 HcmV?d00001 diff --git a/manifests/Tekton/runs/pipeline/.DS_Store b/manifests/Tekton/runs/pipeline/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0.nip.io`" + - name: GitHubUser + description: "The GitHub user" + - name: GitHubRepo + description: "The GitHub repo where the webhook will be created" + - name: GitHubOrg + description: "The GitHub organization where the webhook will be created" + - name: GitHubSecretName + description: "The Secret name for GitHub access token. This is always mounted and must exist" + - name: GitHubAccessTokenKey + description: "The GitHub access token key name" + - name: GitHubSecretStringKey + description: "The GitHub secret string key name" + - name: GitHubDomain + description: "The GitHub domain. Override for GitHub Enterprise" + default: "github.com" + - name: WebhookEvents + description: "List of events the webhook will send notifications for" + default: '[\"push\",\"pull_request\"]' + steps: + - name: create-webhook + image: pstauffer/curl:latest + volumeMounts: + - name: github-secret + mountPath: /var/secret + command: + - sh + args: + - -ce + - | + set -e + echo "Create Webhook" + if [ $(inputs.params.GitHubDomain) = "github.com" ];then + curl -v -d "{\"name\": \"web\",\"active\": true,\"events\": $(inputs.params.WebhookEvents),\"config\": {\"url\": \"https://$(inputs.params.ExternalDomain)\",\"content_type\": \"json\",\"insecure_ssl\": \"1\" ,\"secret\": \"$(cat /var/secret/$(inputs.params.GitHubSecretStringKey))\"}}" -X POST -u $(inputs.params.GitHubUser):$(cat /var/secret/$(inputs.params.GitHubAccessTokenKey)) -L https://api.github.com/repos/$(inputs.params.GitHubOrg)/$(inputs.params.GitHubRepo)/hooks + else + curl -d "{\"name\": \"web\",\"active\": true,\"events\": $(inputs.params.WebhookEvents),\"config\": {\"url\": \"https://$(inputs.params.ExternalDomain)/\",\"content_type\": \"json\",\"insecure_ssl\": \"1\" ,\"secret\": \"$(cat /var/secret/$(inputs.params.GitHubSecretStringKey))\"}}" -X POST -u $(inputs.params.GitHubUser):$(cat /var/secret/$(inputs.params.GitHubAccessTokenKey)) -L https://$(inputs.params.GitHubDomain)/api/v3/repos/$(inputs.params.GitHubOrg)/$(inputs.params.GitHubRepo)/hooks + fi \ No newline at end of file diff --git a/manifests/Tekton/tasks/execute-yaml.yaml b/manifests/Tekton/tasks/execute-yaml.yaml new file mode 100644 index 0000000..2fd6950 --- /dev/null +++ b/manifests/Tekton/tasks/execute-yaml.yaml @@ -0,0 +1,24 @@ + +--- +apiVersion: tekton.dev/v1alpha1 +kind: Task +metadata: + name: execute-yaml + #namespace: stage-tekton-pipeline +spec: + params: + - name: yaml-location + default: deploy.yaml + - name: command + default: apply + workspaces: + - name: source + mountpath: /source + steps: + - name: deploy-new-app + image: lachlanevenson/k8s-kubectl + command: ["kubectl"] + args: + - "$(params.command)" + - "-f" + - "/source/$(params.yaml-location)" \ No newline at end of file diff --git a/manifests/Tekton/tasks/git-clone.yaml b/manifests/Tekton/tasks/git-clone.yaml new file mode 100644 index 0000000..b38e1dd --- /dev/null +++ b/manifests/Tekton/tasks/git-clone.yaml @@ -0,0 +1,72 @@ +--- +apiVersion: tekton.dev/v1alpha1 +kind: Task +metadata: + name: git-clone +spec: + workspaces: + - name: output + description: workspace the repo will be cloned into + params: + - name: url + 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)" + cleandir() { + if [[ -d "$CHECKOUT_DIR" ]] ; then + rm -rf "$CHECKOUT_DIR"/* + rm -rf "$CHECKOUT_DIR"/.[!.]* + 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) \ No newline at end of file diff --git a/manifests/Tekton/triggers/event-listener.yaml b/manifests/Tekton/triggers/event-listener.yaml new file mode 100644 index 0000000..14a2e16 --- /dev/null +++ b/manifests/Tekton/triggers/event-listener.yaml @@ -0,0 +1,36 @@ + +--- +apiVersion: tekton.dev/v1alpha1 +kind: EventListener +metadata: + name: github-event-listener +spec: + serviceAccountName: service-acc + triggers: + - name: github + # interceptors: + # - github: + # eventTypes: + # - pull_request + # - push + bindings: + - name: github-trigger-binding + template: + name: github-trigger-template + +--- +apiVersion: v1 +kind: Service +metadata: + name: manual-service +spec: + ports: + - name: http-listener + port: 8080 + protocol: TCP + targetPort: 8080 + selector: + app.kubernetes.io/managed-by: EventListener + app.kubernetes.io/part-of: Triggers + eventlistener: github-event-listener + type: LoadBalancer \ No newline at end of file diff --git a/manifests/Tekton/triggers/trigger-binding.yaml b/manifests/Tekton/triggers/trigger-binding.yaml new file mode 100644 index 0000000..c1d7952 --- /dev/null +++ b/manifests/Tekton/triggers/trigger-binding.yaml @@ -0,0 +1,18 @@ +--- +apiVersion: tekton.dev/v1alpha1 +kind: TriggerBinding +metadata: + name: github-trigger-binding + #namespace: stage-tekton-pipeline +spec: + params: + - name: gitrevision + value: $(body.repository.default_branch) + - name: gitrepositoryurl + value: $(body.repository.clone_url) + # - name: prurl + # value: $(body.pull_request.html_url) + # - name: repo + # value: $(body.pull_request.base.repo.full_name) + # - name: source + # value: github \ No newline at end of file diff --git a/manifests/Tekton/triggers/trigger-template.yaml b/manifests/Tekton/triggers/trigger-template.yaml new file mode 100644 index 0000000..b3f9a58 --- /dev/null +++ b/manifests/Tekton/triggers/trigger-template.yaml @@ -0,0 +1,35 @@ +--- +apiVersion: tekton.dev/v1alpha1 +kind: TriggerTemplate +metadata: + name: github-trigger-template + #namespace: stage-tekton-pipeline +spec: + params: + - name: gitrevision + description: The git revision + default: master + - name: gitrepositoryurl + description: The git repository url + resourcetemplates: + - apiVersion: tekton.dev/v1alpha1 + kind: PipelineRun + metadata: + name: application-pipeline-run + #namespace: stage-tekton-pipeline + spec: + serviceAccountName: service-acc + 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. + workspaces: + - name: workspace-master + persistentVolumeClaim: + claimName: workspace-pvc-master + - name: workspace-experimental + persistentVolumeClaim: + claimName: workspace-pvc-experimental + params: + - name: git-url + value: $(inputs.params.gitrepositoryurl) + - name: branch + value: $(inputs.params.gitrevision) \ No newline at end of file diff --git a/manifests/demo.yaml b/manifests/Utilities/event-listener-debug.yaml similarity index 87% rename from manifests/demo.yaml rename to manifests/Utilities/event-listener-debug.yaml index 1e1d6e4..3b5ed7c 100644 --- a/manifests/demo.yaml +++ b/manifests/Utilities/event-listener-debug.yaml @@ -18,8 +18,8 @@ spec: eventlistener: github-event-listener spec: containers: - - name: nginx - image: nginx + - name: network-multitool + image: praqma/network-multitool imagePullPolicy: "Always" ports: - containerPort: 8080 \ No newline at end of file diff --git a/manifests/full-pipeline.yaml b/manifests/full-pipeline.yaml deleted file mode 100644 index 4d431f3..0000000 --- a/manifests/full-pipeline.yaml +++ /dev/null @@ -1,309 +0,0 @@ -# --- -# apiVersion: v1 -# kind: #namespace -# metadata: -# name: stage-tekton-pipeline -# labels: -# istio-injection: enabled #zorgt voor auto sidecar injection ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - name: service-acc - #namespace: stage-tekton-pipeline -secrets: - - name: regcred ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: allow-creation -rules: - - apiGroups: - - "" - - "apps" - - "deploy" -# deze zullen we ook moeten aanpassen elke pipeline die we maken, maar, deze pipelines zijn nu specifiek per branch, dus dit zou geen probleem leveren. - resources: - - pods - - serviceaccounts - - namespaces - - services - - deployments - - deployments.apps - verbs: - - list - - watch - - get - - create - - update - - patch - - delete ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRoleBinding -metadata: - name: allow-creation-binding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: allow-creation -subjects: - - kind: ServiceAccount - name: service-acc - namespace: default ---- -# TODO add git clone task -apiVersion: tekton.dev/v1alpha1 -kind: Task -metadata: - name: git-clone -spec: - workspaces: - - name: output - description: The git repo will be cloned onto the volume backing this workspace - params: - - name: url - 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)" - 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 -kind: Task -metadata: - name: build-and-push -spec: - params: - - name: context - description: The path to the build context, used by Kaniko - within the workspace - default: . - type: string - - name: image-name - description: dockerhub url - type: string - - name: version - description: image-version (for instance latest or beta) - type: string - workspaces: - - name: source - mountpath: /source - steps: - - name: build-and-push - image: gcr.io/kaniko-project/executor - env: - - name: "DOCKER_CONFIG" - value: "/tekton/home/.docker/" - command: - - /kaniko/executor - args: - - "--dockerfile=/source/$(params.context)/dockerfile" - - "--destination=beppev/$(params.image-name):$(params.version)" - - "--context=/source/$(params.context)/" ---- -apiVersion: tekton.dev/v1alpha1 -kind: Task -metadata: - name: execute-yaml - #namespace: stage-tekton-pipeline -spec: - params: - - name: yaml-location - default: deploy.yaml - - name: command - default: apply - workspaces: - - name: source - mountpath: /source - steps: - - name: deploy-new-app - image: lachlanevenson/k8s-kubectl - command: ["kubectl"] - args: - - "$(params.command)" - - "-f" - - "/source/$(params.yaml-location)" ---- -apiVersion: tekton.dev/v1beta1 -kind: Pipeline -metadata: - name: application-pipeline - #namespace: stage-tekton-pipeline -spec: - params: - - name: git-url - description: url of the github repository to clone - - name: branch - description: name of the master branch of the repository - workspaces: - - name: workspace-master - - name: workspace-experimental - tasks: - - name: clone-master - taskRef: - name: git-clone - workspaces: - - name: output - workspace: workspace-master - params: - - name: url - value: $(inputs.params.git-url) - - name: revision - value: $(inputs.params.master-branch) - - name: build-and-push-a - taskRef: - name: build-and-push - runAfter: - - clone-master - workspaces: - - name: source - workspace: workspace-master - params: - - name: context - value: "server-a" - - name: image-name - value: "server-a" - - name: version - value: "$(inputs.params.master-branch)" - - name: build-and-push-b-stable - taskRef: - name: build-and-push - runAfter: - - clone-master - workspaces: - - name: source - workspace: workspace-master - params: - - name: context - value: "server-b" - - name: image-name - value: "server-b" - - name: version - value: "$(inputs.params.master-branch)" - - name: build-and-push-d - taskRef: - name: build-and-push - runAfter: - - clone-master - workspaces: - - name: source - workspace: workspace-master - params: - - name: context - value: "server-d" - - name: image-name - value: "server-d" - - name: version - value: "$(inputs.params.master-branch)" - - name: clone-experimental - taskRef: - name: git-clone - workspaces: - - name: output - workspace: workspace-experimental - params: - - name: url - value: $(inputs.params.git-url) - - name: revision - value: $(inputs.params.experimental-branch) - - name: build-and-push-b-experimental - taskRef: - name: build-and-push - workspaces: - - name: source - workspace: workspace-experimental - runAfter: - - clone-experimental - 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-master - runAfter: - - build-and-push-b-experimental - - build-and-push-d - - build-and-push-a - - build-and-push-b-stable - 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-master - runAfter: - - deploy-infra diff --git a/manifests/github-event-listener.yaml b/manifests/github-event-listener.yaml deleted file mode 100644 index 6e6b844..0000000 --- a/manifests/github-event-listener.yaml +++ /dev/null @@ -1,141 +0,0 @@ -# 1 trigger binding wordt geconfigureerd, en dan worden meerdere trigger templates aangemaakt -# voor de verschillende service mesh types. Op deze manier moet ik niet elke keer een aparte pipeline aanmaken per service mesh type. Het nadeel hieraan is dat dan elke keer elke pipeline gerunned wordt, maar uiteindelijk maakt dit niet veel uit zolang de deploy.yaml files leeg zijn wanneer de commits door gaan ---- -apiVersion: tekton.dev/v1alpha1 -kind: TriggerBinding -metadata: - name: github-trigger-binding - #namespace: stage-tekton-pipeline -spec: - params: - - name: gitrevision - value: $(body.repository.default_branch) - - name: gitrepositoryurl - value: $(body.repository.clone_url) - # - name: prurl - # value: $(body.pull_request.html_url) - # - name: repo - # value: $(body.pull_request.base.repo.full_name) - # - name: source - # value: github ---- -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - name: workspace-pvc-master -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 500Mi ---- -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - name: workspace-pvc-experimental -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 500Mi ---- -apiVersion: tekton.dev/v1alpha1 -kind: TriggerTemplate -metadata: - name: github-trigger-template - #namespace: stage-tekton-pipeline -spec: - params: - - name: gitrevision - description: The git revision - default: master - - name: gitrepositoryurl - description: The git repository url - resourcetemplates: - - apiVersion: tekton.dev/v1alpha1 - kind: PipelineRun - metadata: - name: application-pipeline-run - #namespace: stage-tekton-pipeline - spec: - serviceAccountName: service-acc - 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. - workspaces: - - name: workspace-master - persistentVolumeClaim: - claimName: workspace-pvc-master - - name: workspace-experimental - persistentVolumeClaim: - claimName: workspace-pvc-experimental - params: - - name: git-url - value: $(inputs.params.gitrepositoryurl) - - name: branch - value: $(inputs.params.gitrevision) ---- -kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: tekton-trigger-role -rules: -- apiGroups: - - "extensions" - - "tekton.dev" - - "" - resources: - - ingresses - - eventlisteners - - triggerbindings - - triggertemplates - - configmaps - - secrets - - pipelineruns - - pipelineresources - - taskruns - - pods - - serviceaccounts - - namespaces - - services - - deployments - - deployments.apps - verbs: - - create - - get - - list - - delete - - update - - watch ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRoleBinding -metadata: - name: tekton-trigger-role-binding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: tekton-trigger-role -subjects: - - kind: ServiceAccount - name: service-acc - namespace: default ---- -apiVersion: tekton.dev/v1alpha1 -kind: EventListener -metadata: - name: github-event-listener -spec: - serviceAccountName: service-acc - triggers: - - name: github - # interceptors: - # - github: - # eventTypes: - # - pull_request - # - push - bindings: - - name: github-trigger-binding - template: - name: github-trigger-template diff --git a/manifests/github-webhook-setup.yaml b/manifests/github-webhook-setup.yaml deleted file mode 100644 index 9f726a8..0000000 --- a/manifests/github-webhook-setup.yaml +++ /dev/null @@ -1,261 +0,0 @@ -# MAKE SURE TO SET UP SECRETS.YAML BEFORE EXAMPLE: -# -# this sets up webhooks for github. you can also do this manually in web gui -# -# -# -# apiVersion: v1 -# kind: Secret -# metadata: -# name: webhook-secret -# #namespace: stage-tekton-pipeline -# stringData: -# token: GITHUBTOKEN -# secret: random-string-data ---- -apiVersion: tekton.dev/v1alpha1 -kind: Task -metadata: - name: create-webhook - #namespace: stage-tekton-pipeline -spec: - volumes: - - name: github-secret - secret: - secretName: $(inputs.params.GitHubSecretName) - inputs: - params: - - name: ExternalDomain - description: "The external domain for the EventListener e.g. `$(inputs.params.EventListenerName)..nip.io`" - - name: GitHubUser - description: "The GitHub user" - - name: GitHubRepo - description: "The GitHub repo where the webhook will be created" - - name: GitHubOrg - description: "The GitHub organization where the webhook will be created" - - name: GitHubSecretName - description: "The Secret name for GitHub access token. This is always mounted and must exist" - - name: GitHubAccessTokenKey - description: "The GitHub access token key name" - - name: GitHubSecretStringKey - description: "The GitHub secret string key name" - - name: GitHubDomain - description: "The GitHub domain. Override for GitHub Enterprise" - default: "github.com" - - name: WebhookEvents - description: "List of events the webhook will send notifications for" - default: '[\"push\",\"pull_request\"]' - steps: - - name: create-webhook - image: pstauffer/curl:latest - volumeMounts: - - name: github-secret - mountPath: /var/secret - command: - - sh - args: - - -ce - - | - set -e - echo "Create Webhook" - if [ $(inputs.params.GitHubDomain) = "github.com" ];then - curl -v -d "{\"name\": \"web\",\"active\": true,\"events\": $(inputs.params.WebhookEvents),\"config\": {\"url\": \"https://$(inputs.params.ExternalDomain)\",\"content_type\": \"json\",\"insecure_ssl\": \"1\" ,\"secret\": \"$(cat /var/secret/$(inputs.params.GitHubSecretStringKey))\"}}" -X POST -u $(inputs.params.GitHubUser):$(cat /var/secret/$(inputs.params.GitHubAccessTokenKey)) -L https://api.github.com/repos/$(inputs.params.GitHubOrg)/$(inputs.params.GitHubRepo)/hooks - else - curl -d "{\"name\": \"web\",\"active\": true,\"events\": $(inputs.params.WebhookEvents),\"config\": {\"url\": \"https://$(inputs.params.ExternalDomain)/\",\"content_type\": \"json\",\"insecure_ssl\": \"1\" ,\"secret\": \"$(cat /var/secret/$(inputs.params.GitHubSecretStringKey))\"}}" -X POST -u $(inputs.params.GitHubUser):$(cat /var/secret/$(inputs.params.GitHubAccessTokenKey)) -L https://$(inputs.params.GitHubDomain)/api/v3/repos/$(inputs.params.GitHubOrg)/$(inputs.params.GitHubRepo)/hooks - fi ---- -# https://medium.com/@nikhilthomas1/cloud-native-cicd-on-openshift-with-openshift-pipelines-tektoncd-pipelines-part-3-github-1db6dd8e8ca7 -apiVersion: tekton.dev/v1alpha1 -kind: TaskRun -metadata: - name: create-repo-webhook - #namespace: stage-tekton-pipeline -spec: - taskRef: - name: create-webhook - inputs: - params: - - name: GitHubOrg - value: "beppevanrolleghem" - - name: GitHubUser - value: "beppevanrolleghem" - - name: GitHubRepo - value: "cicdTest" - - name: GitHubSecretName - value: webhook-secret - - name: GitHubAccessTokenKey - value: token - - name: GitHubSecretStringKey - value: secret - - name: ExternalDomain - value: "ingress.llocal.host" - timeout: 1000s - serviceAccountName: service-acc ---- -apiVersion: v1 -kind: Service -metadata: - name: manual-service -spec: - ports: - - name: http-listener - port: 8080 - protocol: TCP - targetPort: 8080 - selector: - app.kubernetes.io/managed-by: EventListener - app.kubernetes.io/part-of: Triggers - eventlistener: github-event-listener - type: LoadBalancer - - - -# --- -# apiVersion: tekton.dev/v1alpha1 -# kind: Task -# metadata: -# name: create-ingress -# #namespace: stage-tekton-pipeline -# spec: -# volumes: -# - name: work -# emptyDir: {} - -# inputs: -# params: -# - name: CreateCertificate -# description: "Enables/disables the creation of a self-signed certificate for $(inputs.params.ExternalDomain)" -# default: "true" -# - name: CertificateKeyPassphrase -# description: "Phrase that protects private key. This must be provided when the self-signed certificate is created" -# - name: CertificateSecretName -# description: "Secret name for Ingress certificate. The Secret should not exist if the self-signed certificate creation is enabled" -# - name: ExternalDomain -# description: "The external domain for the EventListener e.g. `$(inputs.params.EventListenerName).PROXYIP.nip.io`" -# - name: Service -# description: "The name of the Service used in the Ingress. This will also be the name of the Ingress." -# - name: ServicePort -# description: "The service port that the ingress is being created on" -# - name: ServiceUID -# description: "The uid of the service. If set, this creates an owner reference on the service" -# default: "" - -# steps: -# - name: generate-certificate -# image: frapsoft/openssl -# volumeMounts: -# - name: work -# mountPath: /var/tmp/work -# command: -# - sh -# args: -# - -ce -# - | -# set -e -# cat <