# Concourse Laboratorium Skepping {{#include ../../banners/hacktricks-training.md}} ## Toets Omgewing ### Concourse Loop #### Met Docker-Compose Hierdie docker-compose lêer vereenvoudig die installasie om 'n paar toetse met concourse te doen: ```bash wget https://raw.githubusercontent.com/starkandwayne/concourse-tutorial/master/docker-compose.yml docker-compose up -d ``` U kan die opdraglyn `fly` vir u OS van die web aflaai by `127.0.0.1:8080` #### Met Kubernetes (Aanbeveel) U kan maklik concourse in **Kubernetes** (in **minikube** byvoorbeeld) ontplooi met die helm-kaart: [**concourse-chart**](https://github.com/concourse/concourse-chart). ```bash brew install helm helm repo add concourse https://concourse-charts.storage.googleapis.com/ helm install concourse-release concourse/concourse # concourse-release will be the prefix name for the concourse elements in k8s # After the installation you will find the indications to connect to it in the console # If you need to delete it helm delete concourse-release ``` Na die generering van die concourse omgewing, kan jy 'n geheim genereer en toegang gee aan die SA wat in concourse web loop om K8s geheime te bekom: ```yaml echo 'apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: read-secrets rules: - apiGroups: [""] resources: ["secrets"] verbs: ["get"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: read-secrets-concourse roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: read-secrets subjects: - kind: ServiceAccount name: concourse-release-web namespace: default --- apiVersion: v1 kind: Secret metadata: name: super namespace: concourse-release-main type: Opaque data: secret: MWYyZDFlMmU2N2Rm ' | kubectl apply -f - ``` ### Skep Pyplyn 'n Pyplyn bestaan uit 'n lys van [Jobs](https://concourse-ci.org/jobs.html) wat 'n geordende lys van [Steps](https://concourse-ci.org/steps.html) bevat. ### Stappe Verskeie verskillende tipes stappe kan gebruik word: - **die** [**`task` stap**](https://concourse-ci.org/task-step.html) **voert 'n** [**taak**](https://concourse-ci.org/tasks.html) **uit** - die [`get` stap](https://concourse-ci.org/get-step.html) haal 'n [bron](https://concourse-ci.org/resources.html) op - die [`put` stap](https://concourse-ci.org/put-step.html) werk 'n [bron](https://concourse-ci.org/resources.html) op - die [`set_pipeline` stap](https://concourse-ci.org/set-pipeline-step.html) konfigureer 'n [pyplyn](https://concourse-ci.org/pipelines.html) - die [`load_var` stap](https://concourse-ci.org/load-var-step.html) laai 'n waarde in 'n [lokale var](https://concourse-ci.org/vars.html#local-vars) - die [`in_parallel` stap](https://concourse-ci.org/in-parallel-step.html) voer stappe parallel uit - die [`do` stap](https://concourse-ci.org/do-step.html) voer stappe in volgorde uit - die [`across` stap modifier](https://concourse-ci.org/across-step.html#schema.across) voer 'n stap verskeie kere uit; een vir elke kombinasie van veranderlike waardes - die [`try` stap](https://concourse-ci.org/try-step.html) probeer om 'n stap uit te voer en slaag selfs al misluk die stap Elke [stap](https://concourse-ci.org/steps.html) in 'n [job plan](https://concourse-ci.org/jobs.html#schema.job.plan) loop in sy **eie houer**. Jy kan enigiets wat jy wil binne die houer uitvoer _(d.w.s. voer my toetse uit, voer hierdie bash-skrip uit, bou hierdie beeld, ens.)_. So as jy 'n werk het met vyf stappe, sal Concourse vyf houers skep, een vir elke stap. Daarom is dit moontlik om die tipe houer aan te dui waarin elke stap uitgevoer moet word. ### Eenvoudige Pyplyn Voorbeeld ```yaml jobs: - name: simple plan: - task: simple-task privileged: true config: # Tells Concourse which type of worker this task should run on platform: linux image_resource: type: registry-image source: repository: busybox # images are pulled from docker hub by default run: path: sh args: - -cx - | sleep 1000 echo "$SUPER_SECRET" params: SUPER_SECRET: ((super.secret)) ``` ```bash fly -t tutorial set-pipeline -p pipe-name -c hello-world.yml # pipelines are paused when first created fly -t tutorial unpause-pipeline -p pipe-name # trigger the job and watch it run to completion fly -t tutorial trigger-job --job pipe-name/simple --watch # From another console fly -t tutorial intercept --job pipe-name/simple ``` Kontroleer **127.0.0.1:8080** om die pypuntvloei te sien. ### Bash-skrip met uitvoer/invoer pypunt Dit is moontlik om **die resultate van een taak in 'n lêer te stoor** en aan te dui dat dit 'n uitvoer is en dan die invoer van die volgende taak as die uitvoer van die vorige taak aan te dui. Wat concourse doen, is om **die gids van die vorige taak in die nuwe taak te monteer waar jy toegang kan hê tot die lêers wat deur die vorige taak geskep is**. ### Triggers Jy hoef nie die werksgeleenthede handmatig te aktiveer elke keer wanneer jy hulle moet uitvoer nie, jy kan ook program dat hulle elke keer uitgevoer word: - 'n Bietjie tyd verby: [Time resource](https://github.com/concourse/time-resource/) - Op nuwe verbintenisse na die hooftak: [Git resource](https://github.com/concourse/git-resource) - Nuwe PR's: [Github-PR resource](https://github.com/telia-oss/github-pr-resource) - Laai die nuutste beeld van jou app af of druk dit: [Registry-image resource](https://github.com/concourse/registry-image-resource/) Kontroleer 'n YAML-pypuntvoorbeeld wat aktiveer op nuwe verbintenisse na meester in [https://concourse-ci.org/tutorial-resources.html](https://concourse-ci.org/tutorial-resources.html) {{#include ../../banners/hacktricks-training.md}}