-
Notifications
You must be signed in to change notification settings - Fork 0
feat: tailscale-operator Workload Identity(beta) - infra #7333
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
Open
boxp
wants to merge
13
commits into
main
Choose a base branch
from
T-20260302-009-tailscale-wif
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f9da182
feat: tailscale-operator WIF(beta) - S3 OIDC, WIF credential, kubeadm…
claude 30028b1
fix: add S3 OIDC dependency to k8s_operator WIF resource
claude 1281c16
fix: add trivy ignores for public OIDC bucket, add bucket policy dep
claude 3c2a245
style: terraform fmt -recursive
boxp-tfaction[bot] 7c98c80
Merge branch 'main' into T-20260302-009-tailscale-wif
boxp-tfaction[bot] 7c3ac8b
Merge branch 'main' into T-20260302-009-tailscale-wif
boxp-tfaction[bot] a0ac8ec
Merge branch 'main' into T-20260302-009-tailscale-wif
boxp-tfaction[bot] 71f3a7e
Merge branch 'main' into T-20260302-009-tailscale-wif
boxp-tfaction[bot] d7a8e0d
Merge branch 'main' into T-20260302-009-tailscale-wif
boxp-tfaction[bot] a5cce57
Merge branch 'main' into T-20260302-009-tailscale-wif
boxp-tfaction[bot] 82fcb28
Merge branch 'main' into T-20260302-009-tailscale-wif
boxp-tfaction[bot] 78046dc
Merge branch 'main' into T-20260302-009-tailscale-wif
boxp-tfaction[bot] 836a891
Merge branch 'main' into T-20260302-009-tailscale-wif
boxp-tfaction[bot] 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,102 @@ | ||
| # S3-hosted OIDC Discovery for the lolice kubeadm cluster. | ||
| # | ||
| # Tailscale Workload Identity Federation requires the OIDC issuer to be | ||
| # publicly accessible. Since the lolice API server lives on a private | ||
| # network, we publish the two required discovery documents in an S3 | ||
| # bucket with public-read access. | ||
| # | ||
| # After the first apply, upload the real JWKS by extracting the SA | ||
| # signing public key from a control-plane node: | ||
| # | ||
| # kubectl get --raw /openid/v1/jwks > /tmp/jwks.json | ||
| # aws s3 cp /tmp/jwks.json s3://lolice-k8s-oidc/openid/v1/jwks \ | ||
| # --content-type application/json | ||
| # | ||
| # Then update the variable k8s_sa_jwks_json with the real content so | ||
| # that future applies do not overwrite it. | ||
|
|
||
| # ── S3 bucket ──────────────────────────────────────────────────────── | ||
|
|
||
| resource "aws_s3_bucket" "k8s_oidc" { | ||
| bucket = "lolice-k8s-oidc" | ||
| } | ||
|
|
||
| resource "aws_s3_bucket_public_access_block" "k8s_oidc" { | ||
| bucket = aws_s3_bucket.k8s_oidc.id | ||
|
|
||
| # Allow public read via bucket policy (required for OIDC discovery). | ||
| block_public_acls = true | ||
| ignore_public_acls = true | ||
|
|
||
| # Public policy and buckets must be allowed so Tailscale can fetch the | ||
| # OIDC discovery documents without authentication. | ||
| block_public_policy = false #trivy:ignore:AVD-AWS-0087 -- intentional: OIDC discovery must be public | ||
| restrict_public_buckets = false #trivy:ignore:AVD-AWS-0093 -- intentional: OIDC discovery must be public | ||
| } | ||
|
|
||
| resource "aws_s3_bucket_policy" "k8s_oidc_public_read" { | ||
| bucket = aws_s3_bucket.k8s_oidc.id | ||
|
|
||
| policy = jsonencode({ | ||
| Version = "2012-10-17" | ||
| Statement = [ | ||
| { | ||
| Sid = "AllowPublicReadOIDC" | ||
| Effect = "Allow" | ||
| Principal = "*" | ||
| Action = "s3:GetObject" | ||
| Resource = [ | ||
| "${aws_s3_bucket.k8s_oidc.arn}/.well-known/openid-configuration", | ||
| "${aws_s3_bucket.k8s_oidc.arn}/openid/v1/jwks", | ||
| ] | ||
| }, | ||
| ] | ||
| }) | ||
|
|
||
| depends_on = [aws_s3_bucket_public_access_block.k8s_oidc] | ||
| } | ||
|
|
||
| resource "aws_s3_bucket_server_side_encryption_configuration" "k8s_oidc" { | ||
| bucket = aws_s3_bucket.k8s_oidc.id | ||
|
|
||
| rule { | ||
| apply_server_side_encryption_by_default { | ||
| sse_algorithm = "AES256" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| # ── OIDC Discovery document ───────────────────────────────────────── | ||
|
|
||
| locals { | ||
| oidc_issuer_url = "https://${aws_s3_bucket.k8s_oidc.bucket_regional_domain_name}" | ||
| } | ||
|
|
||
| resource "aws_s3_object" "oidc_discovery" { | ||
| bucket = aws_s3_bucket.k8s_oidc.id | ||
| key = ".well-known/openid-configuration" | ||
| content_type = "application/json" | ||
|
|
||
| content = jsonencode({ | ||
| issuer = local.oidc_issuer_url | ||
| jwks_uri = "${local.oidc_issuer_url}/openid/v1/jwks" | ||
| response_types_supported = ["id_token"] | ||
| subject_types_supported = ["public"] | ||
| id_token_signing_alg_values_supported = ["RS256"] | ||
| }) | ||
| } | ||
|
|
||
| # ── JWKS document ──────────────────────────────────────────────────── | ||
| # The initial content is a placeholder. Replace with the real JWKS | ||
| # extracted from the cluster (see header comment). | ||
|
|
||
| resource "aws_s3_object" "oidc_jwks" { | ||
| bucket = aws_s3_bucket.k8s_oidc.id | ||
| key = "openid/v1/jwks" | ||
| content_type = "application/json" | ||
| content = var.k8s_sa_jwks_json | ||
|
|
||
| lifecycle { | ||
| ignore_changes = [content] | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
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.
tailscale_federated_identity.k8s_operatorcurrently waits for the two S3 objects but not foraws_s3_bucket_policy.k8s_oidc_public_read, so on a fresh apply Terraform can start WIF creation while the issuer documents are still private and Tailscale’s issuer validation gets a 403. This makes applies flaky/failing in the exact bootstrap path this commit introduces; include the bucket policy independs_onto guarantee the issuer URL is publicly readable before creating the federated identity.Useful? React with 👍 / 👎.