Concourse Lab Creation
Tip
学习并练习 AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
学习并练习 GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
学习并练习 Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 subscription plans!
- 加入 💬 Discord group 或者 telegram group 或 关注 我们的 Twitter 🐦 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud github 仓库 提交 PRs 来分享 hacking tricks。
测试环境
运行 Concourse
使用 Docker-Compose
此 docker-compose 文件简化了安装,以便进行一些与 concourse 的测试:
wget https://raw.githubusercontent.com/starkandwayne/concourse-tutorial/master/docker-compose.yml
docker-compose up -d
您可以从网络上下载适用于您的操作系统的命令行 fly,地址为 127.0.0.1:8080
使用 Kubernetes(推荐)
您可以使用 helm-chart 轻松地在 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 web 中运行的 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 -
创建管道
管道由一个包含有序列表的 Jobs 组成,该列表包含 Steps。
步骤
可以使用几种不同类型的步骤:
- the
taskstep 运行一个 task - the
getstep 获取一个 resource - the
putstep 更新一个 resource - the
set_pipelinestep 配置一个 pipeline - the
load_varstep 将值加载到 local var 中 - the
in_parallelstep 并行运行步骤 - the
dostep 按顺序运行步骤 - the
acrossstep modifier 多次运行一个步骤;每种变量值组合运行一次 - the
trystep 尝试运行一个步骤,即使步骤失败也会成功
每个 step 在 job plan 中在其 自己的容器 中运行。您可以在容器内运行任何您想要的内容 (即运行我的测试,运行这个 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
检查 127.0.0.1:8080 以查看管道流程。
带有输出/输入管道的 Bash 脚本
可以 将一个任务的结果保存到文件中 并指明它是一个输出,然后将下一个任务的输入指明为上一个任务的输出。Concourse 的做法是 在新任务中挂载上一个任务的目录,以便您可以访问上一个任务创建的文件。
触发器
您不需要每次手动触发作业,您还可以编程使其每次运行时自动触发:
- 一段时间过去: Time resource
- 在主分支的新提交上: Git resource
- 新的 PR: Github-PR resource
- 获取或推送您应用的最新镜像: Registry-image resource
查看一个在主分支新提交时触发的 YAML 管道示例,链接在 https://concourse-ci.org/tutorial-resources.html
Tip
学习并练习 AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
学习并练习 GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
学习并练习 Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 subscription plans!
- 加入 💬 Discord group 或者 telegram group 或 关注 我们的 Twitter 🐦 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud github 仓库 提交 PRs 来分享 hacking tricks。
HackTricks Cloud

