Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/chart-idp-google.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build idp-google chart

on:
push:
tags:
- "v*-idp-google"

pull_request:
branches:
- "*"
paths:
- "idp-google/**"
- ".github/workflows/chart-idp-google.yaml"

workflow_dispatch:

permissions:
contents: read
checks: write
pull-requests: write

jobs:
idp-google-chart:
runs-on: k8shell-runner

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Compute chart version
id: ver
shell: bash
run: |
set -euo pipefail

BASE_VERSION="$(awk '/^version:/ {print $2; exit}' idp-google/Chart.yaml)"
CHART_VERSION="${BASE_VERSION}"
COMMIT_ID=$(git rev-parse --short HEAD)

if [[ "${{ github.event_name }}" == "pull_request" ]]; then
COMMIT_ID=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c1-7)
PR_NUMBER="${{ github.event.pull_request.number }}"
CHART_VERSION="${BASE_VERSION}-pr-${PR_NUMBER}-${COMMIT_ID}"
fi

echo "chart_version=${CHART_VERSION}" >> "$GITHUB_OUTPUT"
echo "Using chart version: ${CHART_VERSION}"

- name: Package helm chart
run: |
mkdir -p dist
helm package idp-google -d dist/ --version "${{ steps.ver.outputs.chart_version }}"

- name: Push helm chart
run: |
helm registry login "${{ secrets.REGISTRY_EXT }}" --username "${{ secrets.HARBOR_USER }}" \
--password "${{ secrets.HARBOR_PASSWORD }}"
helm push dist/*.tgz "oci://${{ secrets.REGISTRY_EXT }}/charts"
3 changes: 3 additions & 0 deletions .github/workflows/chart-k8shell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ jobs:
- name: Package helm chart
run: |
mkdir -p dist
# the NATS subchart (Chart.lock); build needs the repository known
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
helm dependency build k8shell
helm package k8shell -d dist/ --version "${{ steps.ver.outputs.chart_version }}"

- name: Push helm chart
Expand Down
21 changes: 14 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ Each top-level directory is an independent Helm chart published to `oci://ghcr.i

| Chart | Role |
|-------|------|
| `k8shell` | Core platform — the primary chart users install |
| `k8shell-bundle` | Umbrella chart; wraps all charts as ArgoCD `Application` objects |
| `idp-github` / `idp-gitlab` | External identity providers; plugged into k8shell via `identity.remoteProviders` |
| `k8shell` | The whole platform in one chart (2.x): services, PostgreSQL, NATS (subchart), idp-github/idp-google, default policies and blueprints |
| `k8shell-bundle` | Umbrella chart for k8shell 1.x; wraps all charts as ArgoCD `Application` objects. Frozen at 0.7.x, replaced by k8shell 2.x |
| `idp-github` / `idp-gitlab` / `idp-google` | Identity providers as separate charts (used by k8shell-bundle); idp-github and idp-google are also part of the k8shell chart since 2.0 |
| `vault-secrets` | Maps HashiCorp Vault secrets to Kubernetes Secrets |
| `worktrace-detector` | Threat detection engine; DaemonSet consuming Tetragon events (needs Tetragon installed). Ships no rules: a leader-elected `controller` Deployment reads them from an externally provided ConfigMap (`rules.configMap`), serves them to the detectors and generates the TracingPolicy from them |

Expand All @@ -42,27 +42,34 @@ The k8shell chart deploys two tiers of services:

**Core (always enabled):** `ssh-proxy`, `identity`, `provisioner`, `authz`

**Extended (disabled by default, enabled in k8shell-bundle):** `api-server`, `session`, `frontend`
**Extended (enabled by default since 2.0):** `api-server`, `session`, `frontend`, `authz`

**Optional (disabled by default, opt-in even in k8shell-bundle):** `sshShield`

**External dependencies (disabled by default):** `postgresql`, `nats` — toggled via `postgresql.enabled` / `nats.enabled`.
**Infrastructure (installed by default since 2.0):**
- `postgresql` — `postgresql.mode`: `simple` (a single-instance StatefulSet `db-postgresql`, official postgres image, PVC kept on uninstall), `cnpg` (a CloudNativePG `Cluster` `db-postgresql`, operator required) or `external`. The Service `db-postgresql` points at the primary in both installed modes.
- `nats` — `nats.install` adds the official NATS chart as the subchart `natsServer` (values under `natsServer`, `fullnameOverride: nats`). `nats.enabled` still means "the services use NATS"; `templates/validate.yaml` checks that the NATS server reads the same password Secret as the services.
- `k8shell-infra-versions` ConfigMap (versions of the installed PostgreSQL/NATS for api-server) is created automatically.

**Organizations and roles:** identity has no built-in organization. `identity.organizations` (name, description, nodeSelectors, organization-scoped roles) and `identity.roles` (global roles besides the built-in `admin` and `org-admin`; defaults `developer`, `git-workspace`) are rendered into identity's config and created at startup if missing; node selectors are set only while an organization has none. Every entry of `identity.users` needs an `organization` declared there (`templates/validate.yaml`) and gets an onboarding rule with its organization, roles and sudo.

**Identity providers (disabled by default):** `idpGithub`, `idpGoogle` — templates in `templates/idp-github/`, `templates/idp-google/`, using the chart's shared settings (certManager, grpc, authEnabled, imageRegistry, nats, postgresql). Enabled providers are appended to `identity.remoteProviders`; idpGithub also adds the `git-blueprints` ConfigMap (`files/git-blueprints/`) and makes `git-dev` the default custom blueprint.

Service-to-service communication is gRPC. When `certManager.enabled: true`, every service gets a cert-manager-issued TLS certificate and the chart wires mTLS automatically. Without cert-manager, services fall back to plaintext.

JWT auth (`authEnabled: true`) is enforced across all gRPC endpoints. The `identity` service issues tokens signed with the key at `identity.jwtIssuer.privateKey`.

### authz service

`authz` (disabled by default, `authz.enabled: false`) is an OPA-based authorization sidecar on gRPC port 9011. It accepts requests from `ssh-proxy`, `provisioner`, `api-server`, and `identity`. Policies are either mounted from a ConfigMap (`authz.policiesConfigMap`) or fall back to the inline `authz.defaultPolicy` Rego rule. It shares the JWT private key with `identity`.
`authz` (disabled by default, `authz.enabled: false`) is an OPA-based authorization sidecar on gRPC port 9011. It accepts requests from `ssh-proxy`, `provisioner`, `api-server`, and `identity`. The chart ships default policies (`files/policies/*.rego`, ConfigMap `authz-policies-default`); they hold no site-specific settings, permissions follow from roles (`admin`, `org-admin`, `<group>-admin`, `developer` for inject mode, `git-workspace` for repositories). `authz.policiesConfigMap` replaces the whole set with an external ConfigMap. `authz.defaultPolicy` is the inline rule used when no policy file matches. Policy tests: `k8shell/policy-tests/run.sh` (needs opa, jq). It shares the JWT private key with `identity`.

### sshShield service

`sshShield` (disabled by default, `sshShield.enabled: false`) provides SSH brute-force protection. It consumes SSH failure events over the shared `nats` (published by `ssh-proxy` when `sshProxy.publishSshFailures.enabled: true`, subject must match `sshShield.sshFailures.subject`) and bans offending IPs via a pluggable blocker backend (e.g. the `nfgate` plugin). It requires `nats.enabled: true`. It also exposes a gRPC server on port 9040, gated the same way as other services by `certManager.enabled` (TLS) and `authEnabled` (JWT, restricted to the `api-server` service account).

### Blueprints

`provisioner` mounts workspace blueprint YAML from `k8shell/files/blueprints/` (`base.yaml` always; `samples.yaml` when `provisioner.includeBlueprintSamples: true`). Extra blueprints can be injected via `provisioner.blueprintFilesConfigMaps`. When an IDP chart is enabled in k8shell-bundle, a `git-blueprints` ConfigMap is automatically appended to that list.
`provisioner` mounts workspace blueprint YAML from `k8shell/files/blueprints/` (`base.yaml` always; `samples.yaml` when `provisioner.includeBlueprintSamples: true`) as the ConfigMap `blueprint-base-files`; `provisioner.blueprintsConfigMap` replaces it with an external ConfigMap. Extra blueprints are added via `provisioner.blueprintFilesConfigMaps` (file names unique across ConfigMaps, blueprint names unique across files). With idpGithub enabled, `git-blueprints` is appended automatically.

## k8shell-bundle Architecture

Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[![k8shell-bundle chart](https://github.com/k8shell-io/charts/actions/workflows/chart-k8shell-bundle.yaml/badge.svg)](https://github.com/k8shell-io/charts/actions/workflows/chart-k8shell-bundle.yaml)
[![idp-github chart](https://github.com/k8shell-io/charts/actions/workflows/chart-idp-github.yaml/badge.svg)](https://github.com/k8shell-io/charts/actions/workflows/chart-idp-github.yaml)
[![idp-gitlab chart](https://github.com/k8shell-io/charts/actions/workflows/chart-idp-gitlab.yaml/badge.svg)](https://github.com/k8shell-io/charts/actions/workflows/chart-idp-gitlab.yaml)
[![idp-google chart](https://github.com/k8shell-io/charts/actions/workflows/chart-idp-google.yaml/badge.svg)](https://github.com/k8shell-io/charts/actions/workflows/chart-idp-google.yaml)
[![worktrace-detector chart](https://github.com/k8shell-io/charts/actions/workflows/chart-worktrace-detector.yaml/badge.svg)](https://github.com/k8shell-io/charts/actions/workflows/chart-worktrace-detector.yaml)
[![vault-secrets chart](https://github.com/k8shell-io/charts/actions/workflows/chart-vault-secrets.yaml/badge.svg)](https://github.com/k8shell-io/charts/actions/workflows/chart-vault-secrets.yaml)

Expand All @@ -13,14 +14,15 @@ Helm charts for [k8shell](https://k8shell.io) — Cloud-native Development Envir

| Chart | Description |
|-------|-------------|
| [k8shell](./k8shell) | Core k8shell platform — open-source components (ssh-proxy, identity, provisioner) plus extended services (api-server, authz, session, frontend, sshShield). |
| [k8shell-bundle](./k8shell-bundle) | Umbrella chart deploying k8shell together with PostgreSQL, NATS, and Vault-backed secrets. |
| [k8shell](./k8shell) | The k8shell platform in one chart (2.x): the services (ssh-proxy, identity, provisioner, authz, api-server, session, frontend, sshShield), PostgreSQL (single instance, CloudNativePG cluster or external), NATS, the GitHub and Google identity providers, default authz policies and blueprints. |
| [k8shell-bundle](./k8shell-bundle) | Umbrella chart deploying k8shell 1.x together with PostgreSQL, NATS, and Vault-backed secrets as ArgoCD Applications. Frozen at 0.7.x, replaced by k8shell 2.x. |
| [idp-github](./idp-github) | GitHub Identity Provider — authenticates users via GitHub OAuth. |
| [idp-gitlab](./idp-gitlab) | GitLab Identity Provider — authenticates users via GitLab OAuth. |
| [idp-google](./idp-google) | Google Identity Provider — authenticates users via Google OAuth (Workspace and optionally personal accounts). |
| [vault-secrets](./vault-secrets) | Maps HashiCorp Vault secrets to Kubernetes secrets. |
| [worktrace-detector](./worktrace-detector) | Worktrace threat detection engine — runs as a DaemonSet and evaluates Tetragon events against detection rules. |

`k8shell-bundle`, `idp-github`, and `idp-gitlab` are available under the [Early Access Program](https://docs.k8shell.io/licensing#early-access).
`k8shell-bundle`, `idp-github`, `idp-gitlab`, and `idp-google` are available under the [Early Access Program](https://docs.k8shell.io/licensing#early-access).

## Requirements

Expand Down
89 changes: 85 additions & 4 deletions bin/quickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ set -euo pipefail

SCRIPT_VERSION="1.0.0"
CHART_VERSION=""
CHART_REF="oci://registry.k8shell.io/charts/k8shell"
VALUES_FILES=()
ASSUME_YES="false"
REGISTRY_HOST="registry.k8shell.io"
REGISTRY_USERNAME="${K8SHELL_REGISTRY_USERNAME:-}"
REGISTRY_PASSWORD="${K8SHELL_REGISTRY_PASSWORD:-}"
NAMESPACE="k8shell-system"
TARGET_NAMESPACE="k8shell-workspaces"
QUICKSTART_DIR="$HOME/k8shell-quickstart"
QUICKSTART_DIR="${K8SHELL_QUICKSTART_DIR:-$HOME/k8shell-quickstart}"
GENERATED_SSH_KEY="$QUICKSTART_DIR/admin-ssh-key"
NODE_PORT_ENABLED="true"
NODE_PORT="30022"
Expand All @@ -41,6 +47,14 @@ License : AGPL-3.0-or-later — https://github.com/k8shell-io/charts

Options:
-v, --version VERSION Helm chart version (default: latest)
-c, --chart REF Chart to install: OCI reference or local chart
directory (default: $CHART_REF)
-f, --values FILE Additional values file (repeatable), e.g. for a
private registry
-y, --yes Do not ask for confirmation
--registry-username U Username for $REGISTRY_HOST, where the images
come from (or K8SHELL_REGISTRY_USERNAME)
--registry-password P Its password (or K8SHELL_REGISTRY_PASSWORD)
-n, --namespace NS k8shell release namespace (default: $NAMESPACE)
-t, --target-namespace NS Workspace target namespace (default: $TARGET_NAMESPACE)
--node-port PORT Expose SSH via NodePort (default: $NODE_PORT)
Expand All @@ -54,6 +68,11 @@ EOF
while [[ $# -gt 0 ]]; do
case "$1" in
-v|--version) CHART_VERSION="$2"; shift 2 ;;
-c|--chart) CHART_REF="$2"; shift 2 ;;
-f|--values) VALUES_FILES+=("$2"); shift 2 ;;
-y|--yes) ASSUME_YES="true"; shift ;;
--registry-username) REGISTRY_USERNAME="$2"; shift 2 ;;
--registry-password) REGISTRY_PASSWORD="$2"; shift 2 ;;
-n|--namespace) NAMESPACE="$2"; shift 2 ;;
-t|--target-namespace) TARGET_NAMESPACE="$2"; shift 2 ;;
--node-port) NODE_PORT="$2"; shift 2 ;;
Expand Down Expand Up @@ -118,6 +137,17 @@ ensure_ec_key() {
cat "$file"
}

# a random password kept in a file, so upgrades keep it (the database and NATS
# are initialized with it)
ensure_password() {
local file="$1"
if [ ! -f "$file" ]; then
info "Generating password: $file"
(umask 077; openssl rand -hex 24 > "$file")
fi
cat "$file"
}

resolve_admin_public_key() {
# 1. Prefer ~/.ssh/id_rsa.pub if it exists
local default_pub="$HOME/.ssh/id_rsa.pub"
Expand Down Expand Up @@ -192,6 +222,10 @@ EOF

check_prereqs

if [ -z "$REGISTRY_USERNAME" ] || [ -z "$REGISTRY_PASSWORD" ]; then
error "Credentials for $REGISTRY_HOST are required: --registry-username and --registry-password (or K8SHELL_REGISTRY_USERNAME and K8SHELL_REGISTRY_PASSWORD)"
fi

mkdir -p "$QUICKSTART_DIR"

serverKeyDesc=$(describe_ec_key "$QUICKSTART_DIR/server-key.pem" | sed "s|$HOME|~|g")
Expand All @@ -211,15 +245,22 @@ fi

echo
echo " Helm action : $helmAction"
echo " Chart version : ${CHART_VERSION:-latest}"
echo " Chart : $CHART_REF ${CHART_VERSION:-(latest)}"
for f in ${VALUES_FILES[@]+"${VALUES_FILES[@]}"}; do
echo " Values file : $f"
done
echo " Release namespace : $NAMESPACE (will be created if absent)"
echo " Target namespace : $TARGET_NAMESPACE ($targetNsStatus)"
echo " SSH NodePort : $([ "$NODE_PORT_ENABLED" = "true" ] && echo "enabled (port $NODE_PORT)" || echo "disabled")"
echo " SSH proxy key : $serverKeyDesc"
echo " Admin user : admin (sudo enabled, shell: /bin/bash)"
echo " Admin SSH key : $adminKeySource"
echo
read -rp "Proceed with installation? [y/N] " confirm </dev/tty
if [ "$ASSUME_YES" = "true" ]; then
confirm="y"
else
read -rp "Proceed with installation? [y/N] " confirm </dev/tty
fi
case "$confirm" in
[yY][eE][sS]|[yY]) ;;
*) info "Installation cancelled."; exit 0 ;;
Expand All @@ -231,6 +272,8 @@ if [ "$targetNsStatus" = "will be created" ]; then
fi

serverKey=$(ensure_ec_key "$QUICKSTART_DIR/server-key.pem")
dbPassword=$(ensure_password "$QUICKSTART_DIR/db-password")
natsPassword=$(ensure_password "$QUICKSTART_DIR/nats-password")
adminKey=$(generate_admin_public_key)
privateKeyPath=$(resolve_private_key_path | sed "s|$HOME|~|g")

Expand All @@ -244,17 +287,55 @@ fi

info "Running helm $helmAction for k8shell ${CHART_VERSION:-latest}..."

helm $helmAction k8shell oci://ghcr.io/k8shell-io/charts/k8shell \
# Registry credentials as a values file (not --set: passwords may hold
# commas); services pull with the pull Secret, workspaces pull k8shelld through
# the provisioner's private registry.
yamlQuote() { printf "'%s'" "${1//\'/\'\'}"; }
registryValues="$QUICKSTART_DIR/registry-values.yaml"
(umask 077; cat > "$registryValues" <<EOV
imageRegistry:
host: $(yamlQuote "$REGISTRY_HOST")
username: $(yamlQuote "$REGISTRY_USERNAME")
password: $(yamlQuote "$REGISTRY_PASSWORD")
provisioner:
privateRegistry:
enabled: true
host: {value: $(yamlQuote "$REGISTRY_HOST")}
username: {value: $(yamlQuote "$REGISTRY_USERNAME")}
password: {value: $(yamlQuote "$REGISTRY_PASSWORD")}
EOV
)

valuesArgs=(-f "$registryValues")

# the chart itself is in the same registry
if [[ "$CHART_REF" == "oci://$REGISTRY_HOST/"* ]]; then
printf '%s' "$REGISTRY_PASSWORD" | helm registry login "$REGISTRY_HOST" \
--username "$REGISTRY_USERNAME" --password-stdin >/dev/null \
|| error "helm registry login to $REGISTRY_HOST failed"
fi
for f in ${VALUES_FILES[@]+"${VALUES_FILES[@]}"}; do
valuesArgs+=(-f "$f")
done

helm $helmAction k8shell "$CHART_REF" \
${CHART_VERSION:+--version "$CHART_VERSION"} \
${valuesArgs[@]+"${valuesArgs[@]}"} \
--namespace "$NAMESPACE" \
--create-namespace \
--set provisioner.targetNamespace="$TARGET_NAMESPACE" \
--set sshProxy.serverKey.value="$serverKey" \
--set postgresql.username.value=k8shell \
--set postgresql.password.value="$dbPassword" \
--set nats.password.value="$natsPassword" \
--set identity.users[0].username=admin \
--set identity.users[0].uid=1001 \
--set identity.users[0].gid=1001 \
--set identity.users[0].publicKey="$adminKey" \
--set identity.users[0].sudo="true" \
--set identity.users[0].roles[0]=admin \
--set identity.users[0].roles[1]=developer \
--set identity.users[0].organization=default \
--set identity.users[0].shell="/bin/bash" \
--set sshProxy.nodePort.enabled="$NODE_PORT_ENABLED" \
--set sshProxy.nodePort.port="$NODE_PORT"
Expand Down
5 changes: 5 additions & 0 deletions idp-google/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
name: idp-google
description: A Helm chart for Google Identity Provider
version: 0.1.1
appVersion: 0.1.0
Loading
Loading