#JFrog Connector 自动创建 Tekton Task
在此页面上每个集群仅运行一次安装命令(仅限管理员),以安装 Task 和工具镜像 ConfigMap。日常用户只需创建 TaskRun — 请参阅操作指南获取端到端示例,并参阅创建项目时自动配置 JFrog 资源了解如何从命名空间事件运行该 Task。
设置变量,然后运行以下命令:
REGISTRY:存储alauda-connectors/connectors-extensions/jfrog-connector-automatic-creation镜像的 registry 主机。TARGET_NS:要安装 Task 的命名空间。工具镜像 ConfigMap 将安装在kube-public中。
export REGISTRY=<your-registry>
export TARGET_NS=<target-namespace>
cat <<'EOF' | envsubst '${REGISTRY} ${TARGET_NS}' | kubectl apply -f -
apiVersion: v1
data:
image: ${REGISTRY}/alauda-connectors/connectors-extensions/jfrog-connector-automatic-creation:v1.12.0-rc.359.g2f1d81e
name: JFrog Connector Automatic Creation v0.1
kind: ConfigMap
metadata:
annotations:
operator.tekton.dev/preserve-namespace: "true"
operator.tekton.dev/resource-policy: keep
labels:
catalog.tekton.dev/source: system
catalog.tekton.dev/tool-image-jfrog-connector-automatic-creation: "0.1"
catalog.tekton.dev/tool-image-run-script: jfrog-connector-automatic-creation-0.1
operator.tekton.dev/tool-image: jfrog-connector-automatic-creation
name: catalog-tool-image-jfrog-connector-automatic-creation-0.1
namespace: kube-public
---
apiVersion: v1
data:
image: ${REGISTRY}/alauda-connectors/connectors-extensions/jfrog-connector-automatic-creation:latest
name: JFrog Connector Automatic Creation latest
kind: ConfigMap
metadata:
annotations:
operator.tekton.dev/preserve-namespace: "true"
labels:
catalog.tekton.dev/source: system
catalog.tekton.dev/tool-image-jfrog-connector-automatic-creation: latest
catalog.tekton.dev/tool-image-run-script: jfrog-connector-automatic-creation-latest
operator.tekton.dev/tool-image: jfrog-connector-automatic-creation
name: catalog-tool-image-jfrog-connector-automatic-creation-latest
namespace: kube-public
---
apiVersion: tekton.dev/v1
kind: Task
metadata:
annotations:
style.tekton.dev/descriptors: |
- path: params.connector
x-descriptors:
- urn:alm:descriptor:label:en:Connector
- 'urn:alm:descriptor:description:en:Target JFrog Connector resource to create or update, in [ns]/[name] format, for example project-a/jfrog. The auth Secret is written to the same namespace'
- urn:alm:descriptor:com.tectonic.ui:text
- urn:alm:descriptor:com.tectonic.ui:validation:required
- path: params.jfrogUrl
x-descriptors:
- urn:alm:descriptor:label:en:Artifactory URL
- 'urn:alm:descriptor:description:en:Artifactory origin, for example https://jfrog.example.com — do NOT include the /artifactory context path. Used as the Connector address, the admin API base, and the auths key authority of generated image pull Secrets'
- urn:alm:descriptor:com.tectonic.ui:text
- urn:alm:descriptor:com.tectonic.ui:validation:required
- path: params.jfrogRepositories
x-descriptors:
- urn:alm:descriptor:label:en:Repositories
- 'urn:alm:descriptor:description:en:YAML with two optional top-level keys. provision: entries are created when absent and left untouched when they already exist. reference: entries must already exist and are only linked into the permission target — a missing one fails the run rather than being created. At least one entry across both lists is required. A provision entry takes name + packageType (docker | maven | npm | pypi | generic | ...) plus an optional rclass (default local); a reference entry takes name only. Example — provision: [{name: project-a-docker, packageType: docker}, {name: project-a-maven, packageType: maven}], reference: [{name: shared-maven-virtual}]'
- 'urn:alm:descriptor:tooltip:en:Block style and flow style both parse, so the one-line example in the description can be pasted as-is. Full schema and worked examples in the Task README.'
- urn:alm:descriptor:com.tectonic.ui:textarea
- urn:alm:descriptor:com.tectonic.ui:validation:required
- path: params.permissions
x-descriptors:
- urn:alm:descriptor:label:en:Permissions
- 'urn:alm:descriptor:description:en:Actions granted over every listed repository. Artifactory defines read (pull / resolve), write (deploy a new artifact), annotate (set properties and metadata), delete (remove an artifact — and also overwrite one that already exists) and manage (edit the repository permissions themselves). Defaults to read alone. Note the delete semantics: a write-only grant can create artifacts but not replace them.'
- 'urn:alm:descriptor:tooltip:en:One action per entry. Passed through to Artifactory verbatim — an action it does not recognise is rejected by Artifactory, not by this Task.'
- urn:alm:descriptor:com.tectonic.ui:tagsInput
- path: params.secret
x-descriptors:
- urn:alm:descriptor:label:en:Secret Name
- 'urn:alm:descriptor:description:en:Optional override for the Connector auth Secret name. Default = [connector-name]-secret'
- urn:alm:descriptor:com.tectonic.ui:text
- path: params.jfrogUser
x-descriptors:
- urn:alm:descriptor:label:en:Artifactory Username
- 'urn:alm:descriptor:description:en:Optional override for the generated Artifactory user. Default = connector-[ns]-[connector], folded to Artifactory 58-character limit when needed. A value given here must already fit'
- urn:alm:descriptor:com.tectonic.ui:text
- path: params.jfrogGroup
x-descriptors:
- urn:alm:descriptor:label:en:Artifactory Group Prefix
- 'urn:alm:descriptor:description:en:Optional override for the group PREFIX. The real group carries a generation suffix, [prefix]-[n]; advancing it is what makes a rotated credential stop working'
- urn:alm:descriptor:com.tectonic.ui:text
- path: params.tokenExpiry
x-descriptors:
- urn:alm:descriptor:label:en:Token Expiry
- 'urn:alm:descriptor:description:en:How long the access token stays valid. Write a duration — 30d, 12h, 1h30m — with units s, m, h, d; a bare number is read as seconds, and 0 means the token never expires. Default 30d. Nothing re-runs this Task on a schedule, so a credential lapses if the Task is never rerun within its lifetime.'
- 'urn:alm:descriptor:tooltip:en:Same units as a Go duration plus d for days, which Go itself does not accept.'
- urn:alm:descriptor:com.tectonic.ui:text
- path: params.tokenPolicy
x-descriptors:
- urn:alm:descriptor:label:en:Token Policy
- 'urn:alm:descriptor:description:en:reuse keeps a stored token that is not near expiry; refresh performs a real rotation that also invalidates the previous token'
- urn:alm:descriptor:com.tectonic.ui:select
- urn:alm:descriptor:com.tectonic.default:reuse
- urn:alm:descriptor:props:select:options:reuse
- urn:alm:descriptor:props:select:options:refresh
- path: params.tokenRenewBeforeDays
x-descriptors:
- urn:alm:descriptor:label:en:Renew Before (days)
- 'urn:alm:descriptor:description:en:Under tokenPolicy reuse, re-mint when the stored token expires within this many days'
- urn:alm:descriptor:com.tectonic.ui:text
- path: params.imagePullSecrets
x-descriptors:
- urn:alm:descriptor:label:en:Image Pull Secrets
- 'urn:alm:descriptor:description:en:dockerconfigjson Secrets to create, one [ns]/[name] per entry — several namespaces can receive the credential in a single run. For docker repositories. Additive: dropping an entry later does not delete the Secret.'
- urn:alm:descriptor:com.tectonic.ui:tagsInput
- path: params.bindImagePullSecretToSA
x-descriptors:
- urn:alm:descriptor:label:en:Bind Pull Secrets to ServiceAccount
- 'urn:alm:descriptor:description:en:Append each generated image pull Secret to the ServiceAccount in every target namespace. The append preserves entries this Task did not create and does not duplicate on rerun'
- urn:alm:descriptor:com.tectonic.ui:select
- urn:alm:descriptor:com.tectonic.default:true
- urn:alm:descriptor:props:select:options:true
- urn:alm:descriptor:props:select:options:false
- path: params.serviceAccountName
x-descriptors:
- urn:alm:descriptor:label:en:ServiceAccount Name
- 'urn:alm:descriptor:description:en:Existing ServiceAccount that receives the generated image pull Secrets when the binding above is enabled'
- urn:alm:descriptor:com.tectonic.ui:text
- path: params.jfrogCliImage
x-descriptors:
- urn:alm:descriptor:label:en:Task Tool Image
- 'urn:alm:descriptor:description:en:Runtime image providing curl + jq + yq + kubectl + bash and the helper scripts that drive Artifactory. Must be the jfrog-connector-automatic-creation image or a derivative bundling the helper scripts at /usr/local/bin/ — a generic kubectl image will not work'
- urn:alm:descriptor:com.tectonic.ui:select:image
- urn:alm:descriptor:expression:props.options:api:/kubernetes/${context.cluster}/api/v1/namespaces/kube-public/configmaps?labelSelector=catalog.tekton.dev%2Ftool-image-jfrog-connector-automatic-creation
- urn:alm:descriptor:props:select:allowCreate
- urn:alm:descriptor:expression:props.options:path:items
- urn:alm:descriptor:expression:props.options:label:path:data.name
- urn:alm:descriptor:expression:props.options:value:path:data.image
- path: params.imagePullPolicy
x-descriptors:
- urn:alm:descriptor:label:en:Image Pull Policy
- 'urn:alm:descriptor:description:en:Controls when Kubernetes pulls the tool image used by this Task'
- urn:alm:descriptor:com.tectonic.ui:select
- urn:alm:descriptor:com.tectonic.default:Always
- urn:alm:descriptor:props:select:options:Always
- urn:alm:descriptor:props:select:options:IfNotPresent
- urn:alm:descriptor:props:select:options:Never
- path: params.verbose
x-descriptors:
- urn:alm:descriptor:label:en:Verbose
- 'urn:alm:descriptor:description:en:Emit extra progress detail — the resolved plan, plus one line per Artifactory request with method, path and status code, which is what you would normally reach for set -x to get. Shell tracing is never enabled: bash xtrace prints expanded assignments, so it would log the access token itself. Response bodies are not logged either, because the token request body IS the token.'
- urn:alm:descriptor:com.tectonic.ui:select
- urn:alm:descriptor:com.tectonic.default:false
- urn:alm:descriptor:props:select:options:true
- urn:alm:descriptor:props:select:options:false
style.tekton.dev/displayParams: connector,jfrogUrl,jfrogRepositories,permissions,tokenExpiry,imagePullSecrets,bindImagePullSecretToSA,serviceAccountName,jfrogCliImage
tekton.dev/categories: Developer Tools
tekton.dev/displayName: JFrog Connector Automatic Creation
tekton.dev/pipelines.minVersion: 0.60.0
tekton.dev/platforms: linux/amd64,linux/arm64
tekton.dev/tags: jfrog, artifactory, connectors
labels:
app.kubernetes.io/version: "0.1"
name: jfrog-connector-automatic-creation
namespace: ${TARGET_NS}
spec:
description: |
Reconciles a JFrog Artifactory group, user and permission target scoped to a
caller-supplied set of repositories (provisioned or referenced), mints a scoped access
token, then materialises the tenant `jfrog` Connector plus its auth Secret, syncs
per-namespace credential copies, and optionally binds image pull Secrets to a
ServiceAccount.
Artifactory has no robot accounts. The equivalent is
repository -> permission target -> group -> user, with a token whose
`member-of-groups` claim is evaluated at request time. Ordering is therefore
mandatory: a permission target cannot reference a repository or group that does not
yet exist.
Requires Artifactory **Pro** or higher. On OSS — and on an `artifactory-pro` image
with no licence — the repository, group, user and permission-target APIs all return
`400 This REST API is available only in Artifactory Pro`.
Works against Artifactory 6.20.4 and 7.x from a single code path; it deliberately
avoids `/access/api/v1/*`, which is absent on 6.x and rejects Basic auth on 7.x.
The `jfrog-secret` workspace binds either to a basic-auth Secret or to a mounted
JFrog Connector; the Task auto-detects which.
params:
- description: |
Artifactory origin URL, for example `https://jfrog.example.com`. Do not include
the `/artifactory` context path. Used as the Connector `spec.address`, as the
admin API base, and as the `auths` key authority of generated image pull Secrets.
name: jfrogUrl
type: string
- description: Connector resource to create, in `<namespace>/<name>` format. The auth Secret is written to the same namespace.
name: connector
type: string
- default: ""
description: Connector auth Secret name. Defaults to `<connector-name>-secret`.
name: secret
type: string
- default: ""
description: |
YAML document with two optional top-level keys:
provision: # created when absent, left untouched when present
- name: project-a-docker
packageType: docker # docker | maven | npm | pypi | generic | ...
rclass: local # default: local
reference: # must already exist; linked into the permission target only
- name: shared-maven-virtual
A `provision:` entry that already exists is NOT modified — only a `packageType`
mismatch is warned about. A missing `reference:` entry fails the Task; it is never
created, because a typo in a shared repository name would otherwise produce an
empty stand-in and a green run.
At least one entry across both lists is required.
name: jfrogRepositories
type: string
- default:
- read
description: |
Actions granted to the group over every listed repository. Artifactory defines:
read pull / resolve
write deploy a new artifact
annotate set properties and metadata
delete remove an artifact — and also overwrite one that already exists
manage edit the repository's own permissions
Defaults to `read` alone. Mind the `delete` semantics: a write-only grant can
create artifacts but cannot replace them, because Artifactory treats deploying
over an existing path as a delete.
Values are passed through verbatim; an action Artifactory does not recognise is
rejected by Artifactory, not by this Task.
name: permissions
type: array
- default: ""
description: |
Artifactory user to reconcile. Defaults to
`connector-<connector-namespace>-<connector-name>`.
Artifactory rejects a username longer than 58 characters, which the default
derivation exceeds for ordinary namespace and connector names. A derived name that
does not fit is folded to `<truncated>-<8 hex of its sha256>`; the fold is
deterministic, so both steps arrive at the same identity without sharing state. A
name supplied here is never rewritten — it is refused if it does not fit.
name: jfrogUser
type: string
- default: ""
description: |
Prefix for the Artifactory group this Task reconciles. Defaults to
`connector-<connector-namespace>-<connector-name>`.
The actual group carries a generation suffix, `<prefix>-<n>`, because rotation has
to make the previous credential stop working and repointing the permission target
at a different group is the only thing on Artifactory that does. Token revocation
does not: on Artifactory 6.20.4 and 7.161.26, `POST /token/revoke` reports success
while the token keeps working, and deleting the user has no effect either.
The current generation is read back from the permission target, so no state is
stored anywhere and reruns are safe. Superseded generations are deleted.
A derived prefix longer than 48 characters is folded the same way `jfrogUser` is,
leaving room for the generation suffix. A prefix supplied here must already fit.
name: jfrogGroup
type: string
- default: 30d
description: |
How long the access token stays valid, as a duration: `30d`, `12h`, `1h30m`.
Units are `s`, `m`, `h`, `d` and may be combined. A bare number is read as
seconds, so values written before durations were accepted keep working, and `0`
still means the token never expires.
The unit set is Go's plus `d` for days. Go's own `time.ParseDuration` rejects
`d`, but a token lifetime is the one place where days are the natural unit —
having to write 2592000 for a month is how this parameter gets set wrong.
Artifactory's API takes seconds; the Task converts.
Note that token revocation does NOT work on either Artifactory major — a
non-expiring token is not even persisted, so `POST /token/revoke` reports success
and changes nothing. Expiry is the only lifecycle lever that functions; to revoke
access immediately, delete the permission target or the group.
name: tokenExpiry
type: string
- default: reuse
description: |
`reuse` (default) reads the stored token back from the Connector auth Secret and
keeps it while its expiry is further away than `tokenRenewBeforeDays`, so routine
reruns do not disturb already-distributed credential copies.
`refresh` performs a real rotation: it advances the group generation, repoints the
permission target at the new group, mints a token scoped to it, and deletes the
superseded generations — which makes the PREVIOUS token stop working immediately.
Use it when a credential is suspected compromised.
Either way the `token-rotated` result says what happened.
name: tokenPolicy
type: string
- default: "7"
description: 'Under `tokenPolicy: reuse`, re-mint when the stored token expires within this many days. Rerunning the Task is therefore how a credential gets renewed.'
name: tokenRenewBeforeDays
type: string
- default: []
description: 'Target `kubernetes.io/dockerconfigjson` Secrets to create, in `<namespace>/<name>` format. For docker repositories. Additive: dropping an entry later does not delete the Secret.'
name: imagePullSecrets
type: array
- default: "true"
description: |
Append each generated image pull Secret to the ServiceAccount named by
`serviceAccountName` in every target namespace. Defaults to `"true"`: a pull
Secret nobody is bound to does not make images pullable, so the binding is what
the caller almost always wants.
The append preserves entries this Task did not create and does not duplicate on
rerun. Because `imagePullSecrets` is an atomic list, the binding is a
read-modify-write guarded by the ServiceAccount's resourceVersion and retried on
conflict, so two TaskRuns binding into the same ServiceAccount cannot drop each
other's entry.
Requires `get` and `update` on serviceaccounts in each target namespace.
name: bindImagePullSecretToSA
type: string
- default: default
description: Existing ServiceAccount that receives generated image pull Secrets when `bindImagePullSecretToSA` is `"true"`.
name: serviceAccountName
type: string
- default: ${REGISTRY}/alauda-connectors/connectors-extensions/jfrog-connector-automatic-creation:v1.12.0-rc.359.g2f1d81e
description: |
Runtime image providing `curl`, `jq`, `kubectl`, `bash` and the helper scripts that
drive Artifactory. Must be the `jfrog-connector-automatic-creation` image (or a
derivative bundling the helper scripts at `/usr/local/bin/`) — a generic kubectl
image will not work. This image deliberately contains no JFrog CLI.
name: jfrogCliImage
type: string
- default: Always
description: Image pull policy for all Task steps.
name: imagePullPolicy
type: string
- default: "false"
description: |
Emit extra progress detail: the resolved plan, and one line per Artifactory
request giving method, path and status code — enough to tell which call failed
and with what, which is what you normally reach for `set -x` to get.
Shell tracing is deliberately NOT offered, not even behind this flag. Bash's
xtrace prints expanded assignments, not just command names, so it would log
`TOKEN=eyJ...` and `jq --arg pass eyJ...` regardless of credentials being kept
off command lines. Response bodies are not logged either: the body of the token
request IS the token.
name: verbose
type: string
results:
- description: Repository names reconciled by this run.
name: jfrog-repositories
type: array
- description: Artifactory user reconciled by this run.
name: jfrog-user
type: string
- description: Artifactory group reconciled by this run, including its generation suffix (`<prefix>-<n>`).
name: jfrog-group
type: string
- description: Permission target reconciled by this run.
name: permission-target
type: string
- description: '`<namespace>/<name>` of the written Connector.'
name: connector-ref
type: string
- description: Image pull Secrets written by this run.
name: image-pull-secret-refs
type: array
- description: '`"true"` when a new token was minted and every derived Secret rewritten; `"false"` when the stored token was reused. Callers holding their own copies must re-sync when this is `"true"`.'
name: token-rotated
type: string
stepTemplate:
env:
- name: STATE_DIR
value: /state
- name: VERBOSE
value: $(params.verbose)
- name: CONNECTOR
value: $(params.connector)
- name: WORKSPACE_JFROG_SECRET_BOUND
value: $(workspaces.jfrog-secret.bound)
- name: WORKSPACE_JFROG_SECRET_PATH
value: $(workspaces.jfrog-secret.path)
- name: WORKSPACE_KUBE_CONFIG_BOUND
value: $(workspaces.kube-config.bound)
- name: WORKSPACE_KUBE_CONFIG_PATH
value: $(workspaces.kube-config.path)
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsGroup: 65532
runAsNonRoot: true
runAsUser: 65532
seccompProfile:
type: RuntimeDefault
volumeMounts:
- mountPath: /state
name: state
steps:
- args:
- --permissions
- $(params.permissions[*])
computeResources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 100m
memory: 128Mi
env:
- name: JFROG_URL
value: $(params.jfrogUrl)
- name: REPOSITORIES_YAML
value: $(params.jfrogRepositories)
- name: SECRET
value: $(params.secret)
- name: JFROG_USER
value: $(params.jfrogUser)
- name: JFROG_GROUP
value: $(params.jfrogGroup)
- name: TOKEN_EXPIRY
value: $(params.tokenExpiry)
- name: TOKEN_POLICY
value: $(params.tokenPolicy)
- name: TOKEN_RENEW_BEFORE_DAYS
value: $(params.tokenRenewBeforeDays)
image: $(params.jfrogCliImage)
imagePullPolicy: $(params.imagePullPolicy)
name: ensure-jfrog-resources
script: |
#!/usr/bin/env bash
set -euo pipefail
# The `permissions` array arrives as positional args after a `--permissions`
# marker; fold it into the comma-separated form the helper script takes.
perms=()
collecting="false"
for arg in "$@"; do
if [[ "${arg}" == "--permissions" ]]; then collecting="true"; continue; fi
[[ "${collecting}" == "true" && -n "${arg}" ]] && perms+=("${arg}")
done
(( ${#perms[@]} > 0 )) || perms=(read)
permissions_csv="$(IFS=,; printf '%s' "${perms[*]}")"
# jfrogRepositories is authored as YAML; the helper script takes JSON. JSON input
# is also accepted as-is, since valid JSON is valid YAML.
repos_json='{}'
if [[ -n "${REPOSITORIES_YAML// }" ]]; then
repos_json="$(printf '%s' "${REPOSITORIES_YAML}" | yq -o=json -I=0 '.' )" \
|| { echo "ERROR: jfrogRepositories is not valid YAML or JSON" >&2; exit 1; }
fi
args=(
--jfrog-url "${JFROG_URL}"
--connector "${CONNECTOR}"
--repositories "${repos_json}"
--permissions "${permissions_csv}"
--token-expiry "${TOKEN_EXPIRY}"
--token-policy "${TOKEN_POLICY}"
--token-renew-before-days "${TOKEN_RENEW_BEFORE_DAYS}"
--output-token-file "${STATE_DIR}/token"
--output-rotated-file "${STATE_DIR}/token-rotated"
--output-repos-file "${STATE_DIR}/repos"
--output-identity-file "${STATE_DIR}/identity"
--verbose "${VERBOSE}"
)
[[ -n "${SECRET}" ]] && args+=(--secret "${SECRET}")
[[ -n "${JFROG_USER}" ]] && args+=(--user "${JFROG_USER}")
[[ -n "${JFROG_GROUP}" ]] && args+=(--group-prefix "${JFROG_GROUP}")
exec ensure-jfrog-resources.sh "${args[@]}"
- args:
- --image-pull-secrets
- $(params.imagePullSecrets[*])
computeResources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 100m
memory: 128Mi
env:
- name: JFROG_URL
value: $(params.jfrogUrl)
- name: SECRET
value: $(params.secret)
- name: JFROG_USER
value: $(params.jfrogUser)
- name: BIND_IMAGE_PULL_SECRET_TO_SA
value: $(params.bindImagePullSecretToSA)
- name: SERVICE_ACCOUNT_NAME
value: $(params.serviceAccountName)
image: $(params.jfrogCliImage)
imagePullPolicy: $(params.imagePullPolicy)
name: apply-kubernetes-resources
script: |
#!/usr/bin/env bash
set -euo pipefail
# imagePullSecrets arrives as positional args behind its own marker. `if`, not
# `[[ ... ]] && continue`: bash exempts that from `set -e` today, but the same
# shape with a different right-hand side would not, and this file already says
# elsewhere not to write it.
args=()
for arg in "$@"; do
if [[ "${arg}" == "--image-pull-secrets" || -z "${arg}" ]]; then
continue
fi
args+=(--image-pull-secrets "${arg}")
done
args+=(
--jfrog-url "${JFROG_URL}"
--connector "${CONNECTOR}"
--token-file "${STATE_DIR}/token"
--bind-image-pull-secret-to-sa "${BIND_IMAGE_PULL_SECRET_TO_SA}"
--service-account-name "${SERVICE_ACCOUNT_NAME}"
--output-image-pull-refs "${STATE_DIR}/image-pull-refs"
--verbose "${VERBOSE}"
)
[[ -n "${SECRET}" ]] && args+=(--secret "${SECRET}")
[[ -n "${JFROG_USER}" ]] && args+=(--user "${JFROG_USER}")
exec apply-kubernetes-resources.sh "${args[@]}"
- computeResources:
limits:
cpu: 200m
memory: 128Mi
requests:
cpu: 50m
memory: 64Mi
env:
- name: RESULTS_PATH_REPOS
value: $(results.jfrog-repositories.path)
- name: RESULTS_PATH_USER
value: $(results.jfrog-user.path)
- name: RESULTS_PATH_GROUP
value: $(results.jfrog-group.path)
- name: RESULTS_PATH_PERMISSION_TARGET
value: $(results.permission-target.path)
- name: RESULTS_PATH_CONNECTOR
value: $(results.connector-ref.path)
- name: RESULTS_PATH_IMAGE_PULL_REFS
value: $(results.image-pull-secret-refs.path)
- name: RESULTS_PATH_TOKEN_ROTATED
value: $(results.token-rotated.path)
image: $(params.jfrogCliImage)
imagePullPolicy: $(params.imagePullPolicy)
name: write-results
script: |
#!/usr/bin/env bash
set -euo pipefail
exec write-results.sh
volumes:
- emptyDir:
medium: Memory
name: state
workspaces:
- description: |
Bind either to a basic-auth Secret (`username` + `password` files) or to a mounted
JFrog Connector. The Task detects the binding shape and selects the auth strategy.
A connector-backed mount also ships `.env` (with `HTTP(S)_PROXY`) and `ca.crt`,
which the Task sources so the admin credential never enters the Pod.
name: jfrog-secret
- description: |
Optional kubeconfig for an out-of-cluster target. When unbound, the Task uses the
Pod's in-cluster ServiceAccount.
name: kube-config
optional: true
EOF#参数
从上述 Task 渲染而来,因此不会与刚安装的内容发生偏差。_required_ 默认值表示该参数没有默认值,每个 TaskRun 都必须设置该参数。
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
jfrogUrl | 字符串 | 必需 | Artifactory 源 URL,例如 https://jfrog.example.com。不要包含 /artifactory 上下文路径。用作 Connector 的 spec.address、管理 API 基础 URL,以及所生成镜像拉取 Secret 的 auths 密钥主机。 |
connector | 字符串 | 必需 | 要创建的 Connector 资源,采用 <namespace>/<name> 格式。身份验证 Secret 将写入同一命名空间。 |
secret | 字符串 | "" | Connector 身份验证 Secret 名称。默认为 <connector-name>-secret。 |
jfrogRepositories | 字符串 | "" | 包含两个可选顶级键的 YAML 文档:provision:# 缺失时创建,存在时保持不变 - name: project-a-docker packageType: docker # docker | maven | npm | pypi | generic | ... rclass: local # 默认值:local reference:# 必须已存在;仅链接到权限目标中 - name: shared-maven-virtual 已存在的 provision: 条目不会被修改——仅会警告 packageType 不匹配。缺失的 reference: 条目会导致 Task 失败;它绝不会被创建,因为共享仓库名称中的拼写错误否则会产生空的替代项,并导致运行成功。两个列表合计至少需要一个条目。 |
permissions | 数组 | read | 授予组对所列每个仓库执行的操作。Artifactory 定义的操作包括:read 拉取 / resolve 解析,write 部署新工件,annotate 设置属性和元数据,delete 删除工件——也包括覆盖已有工件,manage 编辑仓库自身的权限。默认为仅 read。注意 delete 的语义:仅写入权限可以创建工件,但不能替换工件,因为 Artifactory 将部署到已有路径视为删除操作。值会原样传递;Artifactory 不识别的操作将由 Artifactory 拒绝,而不是由此 Task 拒绝。 |
jfrogUser | 字符串 | "" | 要协调的 Artifactory 用户。默认为 connector-<connector-namespace>-<connector-name>。Artifactory 拒绝长度超过 58 个字符的用户名,而对于普通的命名空间和 Connector 名称,默认派生名称会超出此限制。不符合长度要求的派生名称会折叠为 <truncated>-<8 hex of its sha256>;折叠是确定性的,因此两个步骤无需共享状态即可得到相同的身份。此处提供的名称不会被重写——如果不符合长度要求,则会被拒绝。 |
jfrogGroup | 字符串 | "" | 此 Task 协调的 Artifactory 组的前缀。默认为 connector-<connector-namespace>-<connector-name>。实际组会携带生成版本后缀 <prefix>-<n>,因为轮换必须使之前的凭证停止工作,而将权限目标重新指向另一个组是 Artifactory 中唯一能做到这一点的操作。令牌撤销无法做到这一点:在 Artifactory 6.20.4 和 7.161.26 上,POST /token/revoke 会报告成功,但令牌仍可继续使用,删除用户也没有效果。当前生成版本会从权限目标中读回,因此不会在任何地方存储状态,重复运行是安全的。已被取代的生成版本会被删除。超过 48 个字符的派生前缀会按照 jfrogUser 的相同方式折叠,为生成版本后缀留出空间。此处提供的前缀必须已经符合长度要求。 |
tokenExpiry | 字符串 | 30d | 访问令牌保持有效的时长,格式为持续时间:30d、12h、1h30m。单位包括 s、m、h、d,并且可以组合使用。纯数字会按秒读取,因此在支持持续时间之前写入的值仍可正常工作,而 0 仍表示令牌永不过期。单位集合是 Go 的单位加上用于表示天数的 d。Go 自带的 time.ParseDuration 会拒绝 d,但令牌有效期是天数最自然的单位——必须为一个月写入 2592000,正是导致此参数设置错误的原因。Artifactory API 接收秒数;Task 会进行转换。请注意,令牌撤销在两个 Artifactory 主版本上均不起作用——永不过期的令牌甚至不会被持久化,因此 POST /token/revoke 会报告成功但不会产生任何变化。过期是唯一有效的生命周期控制手段;若要立即撤销访问权限,请删除权限目标或组。 |
tokenPolicy | 字符串 | reuse | reuse(默认值)会从 Connector 身份验证 Secret 中读回已存储的令牌,并在其距离过期时间超过 tokenRenewBeforeDays 时保留该令牌,因此例行重复运行不会影响已经分发的凭证副本。refresh 会执行真正的轮换:推进组生成版本,将权限目标重新指向新组,生成作用域限定于该组的令牌,并删除已被取代的生成版本——这会使 PREVIOUS 令牌立即停止工作。怀疑凭证已泄露时使用此选项。无论采用哪种方式,token-rotated 结果都会说明发生了什么。 |
tokenRenewBeforeDays | 字符串 | 7 | 在 tokenPolicy: reuse 下,当已存储令牌将在此天数内过期时重新生成令牌。因此,重新运行 Task 即可续订凭证。 |
imagePullSecrets | 数组 | [] | 要创建的目标 kubernetes.io/dockerconfigjson Secret,采用 <namespace>/<name> 格式。适用于 Docker 仓库。采用追加方式:之后删除某个条目不会删除对应的 Secret。 |
bindImagePullSecretToSA | 字符串 | true | "将每个生成的镜像拉取 Secret 追加到每个目标命名空间中由 serviceAccountName 指定的 ServiceAccount。默认为 ""true"":未绑定到任何对象的拉取 Secret 不会使镜像可拉取,因此绑定通常正是调用方所需要的。追加操作会保留此 Task 未创建的条目,并且重复运行时不会产生重复项。由于 imagePullSecrets 是原子列表,绑定操作会在 ServiceAccount 的 resourceVersion 保护下执行读取-修改-写入,并在发生冲突时重试,因此两个 TaskRun 向同一 ServiceAccount 执行绑定时不会丢失对方的条目。要求在每个目标命名空间中的 serviceaccounts 上具有 get 和 update 权限。" |
serviceAccountName | 字符串 | default | "接收生成的镜像拉取 Secret 的现有 ServiceAccount,前提是 bindImagePullSecretToSA 为 ""true""。" |
jfrogCliImage | 字符串 | ${REGISTRY}/alauda-connectors/connectors-extensions/jfrog-connector-automatic-creation:v1.12.0-rc.359.g2f1d81e | 提供 curl、jq、kubectl、bash 以及驱动 Artifactory 的辅助脚本的运行时镜像。必须是 jfrog-connector-automatic-creation 镜像(或在 /usr/local/bin/ 中捆绑辅助脚本的衍生镜像)——通用 kubectl 镜像无法正常工作。此镜像特意不包含 JFrog CLI。 |
imagePullPolicy | 字符串 | Always | 所有 Task 步骤的镜像拉取策略。 |
verbose | 字符串 | false | 输出额外的进度详情:解析后的计划,以及每个 Artifactory 请求的一行信息,包括方法、路径和状态码——足以判断哪个调用失败以及失败原因,这正是通常使用 set -x 所需获取的信息。此处特意不提供 Shell 跟踪功能,即使在此标志后也不提供。Bash 的 xtrace 会打印展开后的赋值,而不仅是命令名称,因此无论凭证是否避开命令行,都会记录 TOKEN=eyJ... 和 jq --arg pass eyJ...。响应正文也不会被记录:令牌请求的正文就是令牌本身。 |
#工作区
| 工作区 | 必需 | 用途 |
|---|---|---|
jfrog-secret | 是 | Artifactory 凭证。可以是通过 Connectors CSI driver 挂载的 JFrog Connector(推荐——凭证会保留在代理后方),也可以是 kubernetes.io/basic-auth Secret。Task 会自动检测所使用的类型。 |
kube-config | 否 | 用于将 Connector 和 Secret 写入另一个集群的 kubeconfig。未绑定时,Task 使用 TaskRun Pod 的集群内 ServiceAccount。 |
#结果
| 结果 | 用途 |
|---|---|
jfrog-repositories | 此次运行协调的仓库名称。 |
jfrog-user | 此次运行协调的 Artifactory 用户。 |
jfrog-group | 组,包括其生成版本后缀。 |
permission-target | 权限目标名称。 |
connector-ref | 所写入 Connector 的 <namespace>/<name>。 |
image-pull-secret-refs | 所写入的每个镜像拉取 Secret,每个命名空间一个条目。 |
token-rotated | 当此次运行生成了新令牌时为 "true"——持有令牌副本的人员必须重新同步;当重复使用已存储的令牌时为 "false"。 |
有关 jfrogRepositories schema、permissions reference、TaskRun 示例、重新运行会更改的内容以及故障排除,请参阅使用 Tekton 自动创建和协调 JFrog Connector 资源。
必须使用 Artifactory Pro(或更高版本)。 此 Task 驱动的仓库、组、用户和权限目标 REST API 属于 Pro 功能;在 OSS 上,这些 API 会返回
400 This REST API is available only in Artifactory Pro。