~ knotless Search/
↑↓ move↵ open⇧↵ all results

johnandersen777.bsky.social/socialweb-computer-console

console.socialweb.computer: kcp, kubectl and ssh compiled to wasm in a browser tab with a terminal; a kcp fork

0
0
main
103 lines · 4.4 KB Raw History
# Tiltfile.static
#
# Static kcp install: unlike the default Tiltfile, this does NOT build the kcp
# and kcp-front-proxy images from local sources and does NOT hot-reload code
# changes. Instead it installs the upstream kcp-operator and lets it deploy the
# upstream, version-matched kcp images. Use this when you want a stable kcp to
# develop *against* rather than to develop kcp itself.
#
# Run with:
#   tilt up -f ./contrib/tilt/Tiltfile.static
# or:
#   make tilt-kind-up-static

load('ext://helm_remote', 'helm_remote')
load('ext://namespace', 'namespace_create')
load("ext://cert_manager", "deploy_cert_manager")

k8s_yaml('kernel-limits-job.yaml')

current_context = k8s_context()

deploy_cert_manager(version='v1.19.2')
k8s_yaml('./issuer.yaml')

namespace_create('envoy-gateway-system')
helm_remote(
  'gateway-helm',
  repo_url='oci://registry-1.docker.io/envoyproxy',
  repo_name='gateway-helm',
  release_name='envoy',
  namespace='envoy-gateway-system',
  version='v1.7.0',
  values=[],
  set=[],
)

# install the gateway and configure tilt to start a port-forward to the
# resulting service that will route the traffic.
# the name of the gateway is random, hence the selector
k8s_yaml('gateway.yaml')
local_resource('ingress', serve_cmd="./port-forward.bash", allow_parallel=True)

# Observability stack (Grafana, Loki, Prometheus, Promtail) is deployed by
# default. External users who don't need it can skip it to save resources and
# startup time by setting KCP_OBSERVABILITY_ENABLED=false (also accepts 0/no/off).
if os.getenv('KCP_OBSERVABILITY_ENABLED', 'true').lower() not in ('false', '0', 'no', 'off'):
    include('./observability/Tiltfile')
else:
    print('Observability stack disabled (KCP_OBSERVABILITY_ENABLED=false)')

# etcd
# builtin kustomize does not support remote urls, see https://github.com/tilt-dev/tilt/issues/2383
k8s_yaml(kustomize('etcd'))

# kcp-operator (upstream)
k8s_yaml(kustomize('./kcp-operator'))

# The kcp custom resources (RootShard, theseus Shard, FrontProxy, their
# TLSRoutes and admin Kubeconfigs) plus kubeconfig extraction are generated by
# the reusable deploy_kcp() module. This Tiltfile owns the infrastructure above
# (cert-manager, envoy gateway, etcd, kcp-operator, observability); deploy_kcp()
# only adds the kcp resources on top. Downstream projects load the same module
# and pass their own gateway/hostnames/auth — see contrib/tilt/kcp_static.Tiltfile.
load('./kcp_static.Tiltfile', 'deploy_kcp')

# Optional image pin and static-token auth, kept as env hooks for parents that
# include this Tiltfile. Empty string → operator defaults / no token auth.
#   KCP_IMAGE_REPO override is for images outside the operator's default repo,
#   e.g. PR builds in ghcr.io/kcp-dev/kcp-prs.
deploy_kcp(
    base_domain='kcp.localhost',
    extra_shards=['theseus'],
    image_repo=os.getenv('KCP_IMAGE_REPO', ''),
    image_tag=os.getenv('KCP_IMAGE_TAG', ''),
    token_auth_secret=os.getenv('KCP_TOKEN_AUTH_SECRET', None) or None,
    token_auth_key=os.getenv('KCP_TOKEN_AUTH_KEY', None) or None,
)

# Portal (contrib-dashboard) — a web UI for kcp workspaces/APIExports served in
# no-oidc mode against the front-proxy. Enabled by default; disable with
# KCP_PORTAL_ENABLED=false (also accepts 0/no/off).
#
# Static: no local build — reuses the checkout's deploy/deployment.yaml but swaps
# its dev image (kcp-dashboard) for the published image, so nothing is built.
# Override the ref with KCP_PORTAL_IMAGE.
if os.getenv('KCP_PORTAL_ENABLED', 'true').lower() not in ('false', '0', 'no', 'off'):
    DASHBOARD_DIR = os.getenv('KCP_PORTAL_DIR', '../../../contrib-dashboard')
    manifest = DASHBOARD_DIR + '/deploy/deployment.yaml'
    if not os.path.exists(manifest):
        fail('contrib-dashboard not found at %s — set KCP_PORTAL_DIR to your checkout ' % DASHBOARD_DIR +
             'or disable the portal with KCP_PORTAL_ENABLED=false')
    portal_image = os.getenv('KCP_PORTAL_IMAGE', 'ghcr.io/kcp-dev/contrib-dashboard:main')
    dashboard_yaml = str(read_file(manifest)).replace('image: kcp-dashboard', 'image: ' + portal_image)
    k8s_yaml(blob(dashboard_yaml))
    k8s_resource('kcp-dashboard',
        port_forwards=['8080:8080'],
        # Wait for the admin kubeconfig secret to be extracted so the mount exists.
        resource_deps=['kcp-admin extract'],
        labels='dashboard',
    )
    print('kcp portal → http://localhost:8080 (no-oidc, static image %s)' % portal_image)
else:
    print('Portal (contrib-dashboard) disabled (KCP_PORTAL_ENABLED=false)')