diff --git a/argocd/applications/url-shortener-ci.yaml b/argocd/applications/url-shortener-ci.yaml new file mode 100644 index 0000000..251a482 --- /dev/null +++ b/argocd/applications/url-shortener-ci.yaml @@ -0,0 +1,22 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: url-shortener-ci + namespace: argocd + annotations: + argocd.argoproj.io/sync-wave: "6" +spec: + project: ci + source: + repoURL: https://git.dahyeon.us/dahyeon/service-state.git + targetRevision: main + path: ci/url-shortener + destination: + server: https://kubernetes.default.svc + namespace: tekton-ci + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - SkipDryRunOnMissingResource=true diff --git a/docs/tekton-ci-cd.md b/docs/tekton-ci-cd.md index cb7f47f..65ac880 100644 --- a/docs/tekton-ci-cd.md +++ b/docs/tekton-ci-cd.md @@ -87,6 +87,27 @@ service-state/ Tekton controllers stay in `tekton-pipelines`. Application PipelineRuns and their credentials run in the isolated `tekton-ci` namespace. +## Registering Additional Service CI + +CI directories in `service-state` are registered explicitly; the service +ApplicationSets discover only `apps/*/overlays/*`. + +For URL shortener, `argocd/applications/url-shortener-ci.yaml` reconciles +`service-state/ci/url-shortener` into `tekton-ci` using the `ci` project. +The platform root Application discovers this registration recursively. + +Cluster-scoped EventListener RBAC belongs in +`platform/tekton/config/eventlistener-rbac.yaml`. Each listener receives a +dedicated ClusterRole and ClusterRoleBinding allowing only `get`, `list`, and +`watch` on `clusterinterceptors` and `clustertriggerbindings`. +Keep ServiceAccounts, Roles, and RoleBindings in `service-state`; remove the +URL shortener ClusterRoleBinding from its `foundation.yaml` when adopting this +registration. The `ci` project intentionally does not allow cluster resources. + +Before the first URL shortener run, configure its Infisical secrets and Gitea +push webhook at `https://tekton-hook.dahyeon.us/url-shortener` as defined in +`service-state/ci/url-shortener`. + ## Code Style Use stable Tekton APIs, explicit names, immutable image references, bounded diff --git a/platform/tekton/config/eventlistener-rbac.yaml b/platform/tekton/config/eventlistener-rbac.yaml index 24b759f..43efe35 100644 --- a/platform/tekton/config/eventlistener-rbac.yaml +++ b/platform/tekton/config/eventlistener-rbac.yaml @@ -25,3 +25,31 @@ subjects: - kind: ServiceAccount name: lolympus-event-listener namespace: tekton-ci +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: url-shortener-tekton-eventlistener-interceptors +rules: + - apiGroups: + - triggers.tekton.dev + resources: + - clusterinterceptors + - clustertriggerbindings + verbs: + - get + - list + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: url-shortener-tekton-eventlistener-interceptors +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: url-shortener-tekton-eventlistener-interceptors +subjects: + - kind: ServiceAccount + name: url-shortener-event-listener + namespace: tekton-ci