-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TektonCD pipeline #63
Closed
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a13a87c
Add TektonCD pipeline
pst 951b817
GKE: Allow using K8s SAs as Google IAM SAs
pst 82cb37a
GKE: Setup pipeline service account in both IAM and K8s
pst 21e6789
GKE: Fix role member
pst 7bfe3db
GKE: Use correct provider for k8s resources
pst 5ff5f3b
Update to TF 0.12.6
pst 5674334
GKE: Link SA and ssh key secret
pst 25029a2
GKE: Make service account name shorter to fit character limit
pst 930f7ef
Add Tekton and Pipeline to quickstart
pst 6fd3e31
Ensure pipeline and task specs conform with TektonCD 0.6.0
pst 4cfd6a3
EKS: Add pipeline.tf to module
pst d898c44
Make TF configuration per cluster pair
pst 8434811
Adapt cluster_services module build_path to new directory layout
pst edde4fb
fixup! Make TF configuration per cluster pair
pst 8036e20
Implement bootstrap first, then adding pipeline flow in tests
pst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
resource "kubernetes_namespace" "pipeline" { | ||
provider = kubernetes.eks | ||
|
||
metadata { | ||
name = "kbst-pipeline" | ||
} | ||
|
||
# namespace metadata may change through the manifests | ||
# hence ignoring this for the terraform lifecycle | ||
lifecycle { | ||
ignore_changes = [metadata] | ||
} | ||
|
||
depends_on = [module.node_pool] | ||
} | ||
|
||
resource "kubernetes_service_account" "pipeline" { | ||
provider = kubernetes.eks | ||
|
||
metadata { | ||
name = "kbst-pipeline" | ||
namespace = kubernetes_namespace.pipeline.metadata[0].name | ||
} | ||
|
||
secret { | ||
name = "ssh-auth" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
locals { | ||
k8s_sa_email = "${var.project}.svc.id.goog[${kubernetes_namespace.pipeline.metadata[0].name}/${kubernetes_service_account.pipeline.metadata[0].name}]" | ||
} | ||
|
||
resource "google_service_account" "pipeline" { | ||
account_id = "${var.metadata_name}-pl" | ||
project = var.project | ||
} | ||
|
||
resource "google_project_iam_member" "container_admin" { | ||
project = var.project | ||
role = "roles/container.admin" | ||
member = "serviceAccount:${google_service_account.pipeline.email}" | ||
} | ||
|
||
resource "google_project_iam_member" "editor" { | ||
project = var.project | ||
role = "roles/editor" | ||
member = "serviceAccount:${google_service_account.pipeline.email}" | ||
} | ||
|
||
resource "google_project_iam_member" "workload_identity_user" { | ||
project = var.project | ||
role = "roles/iam.workloadIdentityUser" | ||
member = "serviceAccount:${local.k8s_sa_email}" | ||
} | ||
|
||
resource "kubernetes_namespace" "pipeline" { | ||
provider = kubernetes.gke | ||
|
||
metadata { | ||
name = "kbst-pipeline" | ||
} | ||
|
||
# namespace metadata may change through the manifests | ||
# hence ignoring this for the terraform lifecycle | ||
lifecycle { | ||
ignore_changes = [metadata] | ||
} | ||
|
||
depends_on = [module.node_pool] | ||
} | ||
|
||
resource "kubernetes_service_account" "pipeline" { | ||
provider = kubernetes.gke | ||
|
||
metadata { | ||
name = "kbst-pipeline" | ||
namespace = kubernetes_namespace.pipeline.metadata[0].name | ||
annotations = { | ||
"iam.gke.io/gcp-service-account" = google_service_account.pipeline.email | ||
} | ||
} | ||
|
||
secret { | ||
name = "ssh-auth" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: v1 | ||
data: | ||
TF_IN_AUTOMATION: "true" | ||
kind: ConfigMap | ||
metadata: | ||
name: env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
commonAnnotations: | ||
catalog.kubestack.com/variant: base | ||
app.kubernetes.io/version: v0.1.0 | ||
|
||
commonLabels: | ||
app.kubernetes.io/component: tektoncd | ||
app.kubernetes.io/managed-by: kubestack | ||
app.kubernetes.io/name: pipeline | ||
|
||
namespace: kbst-pipeline | ||
|
||
resources: | ||
- namespace.yaml | ||
- cm_env.yaml | ||
- pipeline.yaml | ||
- task_terraform_run.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: kbst-pipeline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Pipeline | ||
metadata: | ||
name: kubestack-cd | ||
spec: | ||
params: | ||
- name: ops_or_apps | ||
type: string | ||
default: ops | ||
resources: | ||
- name: source_repo | ||
type: git | ||
tasks: | ||
- name: terraform-run | ||
taskRef: | ||
name: terraform-run | ||
resources: | ||
inputs: | ||
- name: workspace | ||
resource: source_repo | ||
params: | ||
- name: ops_or_apps | ||
value: "$(params.ops_or_apps)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Task | ||
metadata: | ||
name: terraform-run | ||
spec: | ||
inputs: | ||
resources: | ||
- name: workspace | ||
type: git | ||
targetPath: infra | ||
params: | ||
- name: ops_or_apps | ||
type: string | ||
description: Use ops- or apps terraform workspace. | ||
stepTemplate: | ||
workingDir: /workspace/infra | ||
envFrom: | ||
- configMapRef: | ||
name: env | ||
steps: | ||
- name: init | ||
image: kubestack/cd:dev-1 | ||
command: | ||
- terraform | ||
args: | ||
- init | ||
- name: workspace | ||
image: kubestack/cd:dev-1 | ||
command: | ||
- terraform | ||
args: | ||
- workspace | ||
- select | ||
- "$(inputs.params.ops_or_apps)" | ||
- name: plan | ||
image: kubestack/cd:dev-1 | ||
command: | ||
- terraform | ||
args: | ||
- plan | ||
- --input=false | ||
- --out=tfplan | ||
- name: apply | ||
image: kubestack/cd:dev-1 | ||
command: | ||
- terraform | ||
args: | ||
- apply | ||
- --input=false | ||
- tfplan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../pipeline |
12 changes: 12 additions & 0 deletions
12
quickstart/src/manifests/bases/tektoncd/base/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
commonAnnotations: | ||
app.kubernetes.io/version: v0.6.0 | ||
catalog.kubestack.com/heritage: kubestack.com/catalog/tektoncd | ||
catalog.kubestack.com/variant: base | ||
commonLabels: | ||
app.kubernetes.io/component: controller | ||
app.kubernetes.io/managed-by: kubestack | ||
app.kubernetes.io/name: tektoncd | ||
resources: | ||
- release.yaml |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Remember to change directory layout in quickstart too.