-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1095 from GiganticMinecraft/add-tcp-exits-for-deb…
…ugging-internal-microservices add: TCP exits for debugging internal microservices
- Loading branch information
Showing
3 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
seichi-onp-k8s/manifests/seichi-kubernetes/apps/cloudflared-tunnel-exits/tcp-exits.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,66 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: ApplicationSet | ||
metadata: | ||
name: cloudflared-tunnel-tcp-exits | ||
namespace: argocd | ||
spec: | ||
generators: | ||
- list: | ||
# 出口を生成するリスト。 | ||
# オンプレネットワーク内で TCP で公開されているサービスを外部に露出したい時は、 | ||
# このリストに | ||
# - トンネル名の suffix として使われる文字列 (name) | ||
# - 露出されるサービスが外部から見えるようになるドメイン (external-hostname) | ||
# - Pod から見た、サービスが公開されている authority ({{domain-name}}:{{port}} の形式の文字列) (internal-authority) | ||
# の三つのプロパティを持つ要素を追加すればよい。 | ||
elements: | ||
# seichi-game-data-server の gRPC endpoint。 | ||
# 2023/06 現在 Cloudflare tunnel が HTTP/2 をサポートしていないため、TCP サービスとして露出している。 | ||
# デバッグ用途の利用のみを想定しており、 Cloudflare でアクセス制御をしている。 | ||
# | ||
# TODO: できれば SeichiAssist と seichi-game-data-server を手軽にローカルで建てられるようにしたい… | ||
# 2023/06 現状、 SeichiAssist はミニマルに建てようと思っても様々な設定を書く必要があり、 | ||
# (seichi-game-data-server 含めて) 本番環境と同等のものをローカルで動かすまでが大変。 | ||
# SeichiAssist 側に seichi-game-data-server までを含んだサービス群を一発で立ち上げる | ||
# Dockerfile ないし k8s manifest を置くなどすると良いのかもしれない | ||
- name: game-data-server | ||
external-hostname: game-data-server.readonly-internal.onp-k8s.admin.seichi.click | ||
internal-authority: "seichi-game-data-server.seichi-minecraft:80" | ||
template: | ||
metadata: | ||
name: "cloudflared-tunnel-tcp-exit--{{name}}" | ||
namespace: argocd | ||
spec: | ||
project: cloudflared-tunnel-exits | ||
source: | ||
repoURL: https://giganticminecraft.github.io/seichi_infra | ||
chart: cloudflared-tunnel | ||
targetRevision: "1.0.7" | ||
helm: | ||
# サービス一つに対してトンネルを一つずつ生やす | ||
releaseName: cloudflared-tunnel-tcp-exit--{{name}} | ||
values: | | ||
installationName: {{name}} | ||
tunnelNamePrefix: "seichi-onp-k8s--tcp--" | ||
tunnelCredentialSecretName: "cloudflared-tunnel-credential" | ||
tunnelConfigContent: | | ||
ingress: | ||
- hostname: {{external-hostname}} | ||
service: "tcp://{{internal-authority}}" | ||
# Catch-all service | ||
- service: http_status:404 | ||
destination: | ||
server: https://kubernetes.default.svc | ||
namespace: cloudflared-tunnel-exits | ||
syncPolicy: | ||
automated: | ||
prune: true | ||
selfHeal: true | ||
allowEmpty: true | ||
retry: | ||
limit: -1 | ||
backoff: | ||
duration: 5s | ||
factor: 2 | ||
maxDuration: 2m |
39 changes: 39 additions & 0 deletions
39
terraform/cloudflare_network_readonly_internal_services.tf
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,39 @@ | ||
# 整地鯖管理者が、デバッグ目的などで内部的なサービスに接続する必要がある際に経由するネットワーク。 | ||
resource "cloudflare_certificate_pack" "advanced_cert_for_readonly_internal_services" { | ||
zone_id = local.cloudflare_zone_id | ||
type = "advanced" | ||
hosts = [ | ||
local.root_domain, | ||
"*.readonly-internal.onp-k8s.admin.${local.root_domain}", | ||
] | ||
validation_method = "txt" | ||
validity_days = 365 | ||
certificate_authority = "digicert" | ||
cloudflare_branding = false | ||
} | ||
|
||
resource "cloudflare_access_application" "game_data_server" { | ||
zone_id = local.cloudflare_zone_id | ||
name = "Access to game data server" | ||
domain = "game-data-server.readonly-internal.onp-k8s.admin.${local.root_domain}" | ||
type = "self_hosted" | ||
session_duration = "24h" | ||
|
||
http_only_cookie_attribute = true | ||
} | ||
|
||
resource "cloudflare_access_policy" "game_data_server" { | ||
application_id = cloudflare_access_application.game_data_server.id | ||
zone_id = local.cloudflare_zone_id | ||
name = "Require to be in a GitHub team to access" | ||
precedence = "1" | ||
decision = "allow" | ||
|
||
include { | ||
github { | ||
name = local.github_org_name | ||
teams = [github_team.prod_seichi_minecraft_readonly_services_access.slug] | ||
identity_provider_id = cloudflare_access_identity_provider.github_oauth.id | ||
} | ||
} | ||
} |
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