Concourse Lab Creation

Support HackTricks

Testing Environment

Running Concourse

With Docker-Compose

이 docker-compose 파일은 concourse로 몇 가지 테스트를 수행하기 위한 설치를 간소화합니다:

wget https://raw.githubusercontent.com/starkandwayne/concourse-tutorial/master/docker-compose.yml
docker-compose up -d

127.0.0.1:8080에서 귀하의 OS에 맞는 명령줄 fly를 다운로드할 수 있습니다.

Kubernetes를 사용하여 (권장)

헬름 차트를 사용하여 Kubernetes(예: minikube)에 concourse를 쉽게 배포할 수 있습니다: concourse-chart.

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

concourse 환경을 생성한 후, 비밀을 생성하고 concourse 웹에서 실행 중인 SA에 K8s 비밀에 접근할 수 있는 권한을 부여할 수 있습니다:

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 -

파이프라인 생성

파이프라인은 작업 목록으로 구성되며, 여기에는 단계의 정렬된 목록이 포함됩니다.

단계

여러 가지 유형의 단계를 사용할 수 있습니다:

단계작업 계획에서 자신의 컨테이너에서 실행됩니다. 컨테이너 내에서 원하는 모든 것을 실행할 수 있습니다 (예: 내 테스트 실행, 이 bash 스크립트 실행, 이 이미지 빌드 등). 따라서 다섯 개의 단계가 있는 작업이 있다면 Concourse는 각 단계마다 하나씩 다섯 개의 컨테이너를 생성합니다.

따라서 각 단계가 실행되어야 하는 컨테이너 유형을 지정하는 것이 가능합니다.

간단한 파이프라인 예제

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))
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

Check 127.0.0.1:8080 to see the pipeline flow.

Bash script with output/input pipeline

하나의 작업의 결과를 파일에 저장하고 그것이 출력임을 나타낸 다음, 다음 작업의 입력을 이전 작업의 출력으로 나타낼 수 있습니다. concourse가 하는 것은 이전 작업의 디렉토리를 새로운 작업에 마운트하여 이전 작업에서 생성된 파일에 접근할 수 있게 하는 것입니다.

Triggers

작업을 실행할 때마다 수동으로 트리거할 필요가 없으며, 다음과 같이 매번 실행되도록 프로그래밍할 수 있습니다:

https://concourse-ci.org/tutorial-resources.html에서 마스터에 새로운 커밋이 있을 때 트리거되는 YAML 파이프라인 예제를 확인하세요.

Support HackTricks

Last updated