Skip to content
Proyek

Tentang

Platform kontainer yang hemat sumber daya, tanpa daemon, dan kompatibel dengan manifest Kubernetes

Sistem dan infrastruktur

Cara angka ini diukur

Pertumbuhan bintang terukur

dalam 24 jam
0
dalam 7 hari
0
dalam 15 hari
0
dalam 1 bulan
Mengumpulkan riwayat

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

Skate

Mini-paas for deploying kubernetes manifests.

Simpler, daemonless & small resource footprint.

Docs -> skateco.github.io

License Discord

  • Service discovery - DNS based service discovery.
  • Multi-host network - Designed to run on several nodes.
  • Kubernetes manifests - Deploy using the same syntax you use in your day job, without the burden of running k8s yourself.
  • Small resource footprint - Skate is written in rust, runs no daemon of it’s own and uses minimal resources.
  • Https by default - Ingress resources get LetsEncrypt TLS by default.

Born out of the frustration of having to learn yet another deployment configuration file syntax.

Skate runs as a CLI on your machine and talks to a small binary on each host over ssh.

Leverages podman kube play to run pod manifests.

Supported server linux distros:

  • Ubuntu 24.04 (x86_64, aarch64)

  • Fedora 42,43 (x86_64, aarch64)

  • Fedora CoreOS stable (x86_64, aarch64)

    You need to first rebase using the ostree image ghcr.io/skateco/fcos-skate:

    sudo rpm-ostree rebase --reboot ostree-unverified-registry:ghcr.io/skateco/fcos-skate
    

Supported client os: macOs (aarch64), Linux (x86_64, aarch64)

You can deploy:

  • Pods
  • Deployments
  • DaemonSets
  • CronJobs
  • Ingress
  • Secrets
  • ConfigMaps
  • Services

An nginx ingress runs on port 80 and 443 on all nodes. Lets-encrypt provides the certificates.

Getting Started

See the quickstart for a guide on how to get started.

Upgrading from v0.5.x? v1.0.0 needs the cluster recreated; see UPGRADING.md.

Or leeroy jenkins it:

curl -sL https://raw.githubusercontent.com/skateco/skate/refs/heads/main/hack/install-skate.sh | bash

To install a specific release, including a prerelease, set VERSION to its GitHub tag:

curl -sL https://raw.githubusercontent.com/skateco/skate/refs/heads/main/hack/install-skate.sh \
  | VERSION=v1.2.0-rc.1 bash

Without VERSION, the installer uses the latest stable release. The skatelet installer (hack/install-skatelet.sh) accepts the same VERSION selection.

Upgrading nodes

skate create node and skate upgrade node <name> install the skatelet from the GitHub release whose tag matches the running skate (shown by skate --version), prereleases included. A v1.2.0-rc.1 skate installs the v1.2.0-rc.1 skatelet. If that release, or its skatelet asset for the node's platform, isn't published, the command fails and installs nothing; it never falls back to another release. A skate built from an untagged commit has no matching release.

To install a skatelet you built yourself instead, for any skate version, pass it with --skatelet-binary. It must be built for the node's platform:

skate upgrade node node-1 --skatelet-binary ./target/x86_64-unknown-linux-gnu/release/skatelet

Built on

  • Podman
  • Openresty
  • Coredns
  • LVS
  • Keepalived
  • Systemd

ConfigMaps

ConfigMaps are copied to every node. A pod can use the ConfigMaps of its own namespace through envFrom.configMapRef, env.valueFrom.configMapKeyRef and configMap volumes. A pod that references a ConfigMap that doesn't exist fails to start, unless the reference is optional: true.

As in Kubernetes, changing a ConfigMap doesn't restart the pods that use it, and they keep the values they started with. Re-applying the Deployment doesn't pick up the change either, since the Deployment itself hasn't changed. To roll out new values, run:

skate rollout restart deployment/<name> -n <namespace>

binaryData isn't supported, and a ConfigMap's data is limited to 1 MiB. See hack/test-configmap.yaml for an example.

Supported manifest attributes

For pods (which affects deployments, daemonsets and cronjobs), see podman kube play's documentation

For other resources, I'll add some documentation soon. Check ./hack/ for examples of what's been tested.

Workload isolation

Skate runs pods with rootful podman, but each pod gets its own user namespace by default (podman kube play --userns=auto). Root inside a container maps to an unprivileged host UID taken from the containers user's range in /etc/subuid and /etc/subgid, and no two pods share a range. skate create node creates the containers user and allocates that range (1,000,000 IDs, above every existing entry).

Host privileges need a grant

Each node checks every pod against an admission policy before it starts it. A pod that asks for a host privilege its namespace isn't granted is rejected, and the error names the missing grant and the policy file.

A pod runs in the host user namespace (--userns=host, container root is host root) only when it is admitted and asks for at least one of:

  • securityContext.privileged: true on any container
  • hostNetwork, hostPID or hostIPC
  • hostUsers: true
  • a hostPath mounted read-write (including DirectoryOrCreate/FileOrCreate)

Everything else, including a pod whose only host privilege is a read-only hostPath, runs with --userns=auto. Capabilities, sysctls and seccomp/AppArmor/SELinux overrides need grants too, but don't by themselves give host identity. Skate never uses :U or idmapped mounts, so mounting a host path never changes the ownership of host files.

The policy

The policy is /etc/skate/policy.yaml on each node, owned by root. If the file is missing, the node uses the built-in default (src/resources/default-policy.yaml): the skate namespace gets hostNetwork and the /var/lib/skate/dns and /var/lib/skate/ingress host paths that coredns and the ingress need, and every other namespace gets nothing.

To grant namespaces from cluster configuration, add a policy map to the cluster. Each value uses the policy grant fields shown below. These grants are merged with the shipped skate entry. skate and defaults are reserved and cannot be configured; unlisted namespaces stay default-deny. For example:

clusters:
- name: production
  policy:
    monitoring:
      hostPath:
      - prefix: /proc
        readOnly: true
    hp-test:
      hostPath:
      - prefix: /var/lib/skate-test
  nodes: []

Re-running skate create node installs policy changes on each node. A namespace's entry replaces defaults; it isn't merged with it.

version: 1
defaults: {}
namespaces:
  skate:
    hostNetwork: true
    hostPath:
      - prefix: /var/lib/skate/dns
      - prefix: /var/lib/skate/ingress
  # node-exporter style monitoring: reads /proc, keeps its own user namespace
  monitoring:
    hostPath:
      - prefix: /proc
        readOnly: true
  # writes backups to the host, so runs as host root
  backup:
    hostPath:
      - prefix: /srv/backups

Other grants: privileged, hostPID, hostIPC, hostUsers, capabilities (eg [NET_ADMIN]), sysctls (eg [net.core.somaxconn]), seccompUnconfined, appArmorUnconfined, seLinuxOptions and unmaskedProcMount. A hostPath grant covers every path under its prefix; with readOnly: true it covers read-only mounts only. Podman annotations (io.podman.annotations.* and similar) are always rejected.

Breaking change: existing data

Under --userns=auto, container root can't write files owned by host root. Named volumes podman creates for a pod are owned by that pod's mapped UID and work, but data written by older skate versions, and root-owned host paths, isn't writable by isolated pods. Existing clusters must be recreated; there is no in-place migration.

Minimum versions

Nodes need podman 4.9.3 or newer and Linux kernel 6.8 or newer (the tested Ubuntu 24.04 baseline). skate create node checks the kernel and any installed podman before it changes anything on the node; a podman it installs itself is checked right after. Either check fails with the installed and minimum versions.

Persistent volumes

Skate tracks volumes as PersistentVolumeClaim (PVC) resources. Apply one like any other manifest:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: db-data
  namespace: web
spec:
  accessModes: [ReadWriteOnce]
  resources:
    requests:
      storage: 1Gi   # informational, not enforced

A pod mounts it with persistentVolumeClaim: {claimName: db-data}. A claimName with no PVC in the applied files or the cluster gets an implicit PVC of the same name in the pod's namespace, so manifests from before PVCs keep working.

Storage classes

The built-in class skate-local is the default. A PVC without storageClassName uses the StorageClass annotated storageclass.kubernetes.io/is-default-class: "true" if there is one, and skate-local otherwise. StorageClasses are cluster-wide, so applying one takes the admin path (it asks for the sudo password). A PVC's class can't change after it's created.

The built-in class skate-movable lets a pod's volumes follow it to another node (see Moving volumes). A StorageClass with provisioner: skate-movable tunes it:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: rebalancing
provisioner: skate-movable
parameters:
  moveMargin: "120"     # points another node must win by; default 200
  compression: zstd     # zstd (default) or none
  allowMove: "true"     # "false" places volumes exactly like skate-local

Every other class places volumes like skate-local.

Placement

A skate-local volume lives on one node, its home node. The first pod that mounts the PVC is scheduled normally, and the node it lands on becomes the home node. Every later pod that mounts the PVC, including a pod recreated after an edit and every replica of a Deployment, is created on the home node only. If the home node is cordoned, unreachable or gone, the pod isn't created anywhere, the pod that's already running is left alone, and skate apply fails naming the PVC and the node.

Moving volumes

A pod whose PVCs are all skate-movable is placed by score whenever it's created or recreated (an edit, a crash, skate cluster reschedule, a cordon, a nodeSelector change, or a node added with skate create node). Every node that can take the pod is scored as usual, plus a VolumeLocality score: 100 for the home node, and for any other node 100 minus one point per 6 seconds the volumes would take to move there (the PVCs' requested sizes over the rate of the last move between the two nodes; before a move was measured, the slower of the two nodes' probed rates, or a cautious 2 MiB/s). The pod moves only if the best node beats the home node by more than the class's moveMargin. The other scores rank nodes by pod count and free resources, so one extra pod can swing them by up to 200 points; the default margin of 200 means a pod moves only when its home node can't take it (cordoned, unhealthy, or excluded by the pod's nodeSelector). Lower the margin to let pods rebalance.

A move:

  1. stops the pod on the home node, so nothing writes to the volume,
  2. streams each volume, compressed, directly from the home node to the target over SSH (the data never passes through the machine running skate),
  3. imports it into a new volume on the target, owned by the same UID block,
  4. starts the pod on the target, and
  5. makes the target the PVC's home node, and marks the old node's copy stale.

The pod is down for the whole transfer, so a move of a large volume over a slow link takes a while. skate apply --dry-run and skate cluster reschedule --dry-run list each planned move with the volume size and the estimated time, and change nothing. Moves run one at a time, after everything else in the apply. A failed move doesn't stop the others: the pod starts on its home node again and the PVC keeps its home node. A transfer that breaks off leaves no volume on the target; a copy that arrived but whose pod then failed to start stays there unused, and the next move to that node replaces it. Running the command again retries only the moves that didn't complete.

skate create node probes how fast the new node sends to another node (32 MiB of random data, over the same path a move takes), and skate upgrade node probes the node again if its rate is over a week old. skate cluster probe-transfer [--node NAME] probes on demand, eg after rewiring the network. Each node gets one rate, measured against the fastest other node so far, saved in the cluster config; a move between two nodes is estimated at the slower of their rates, since a node's own link (Wi-Fi, a USB dongle) is usually the bottleneck. A failed probe only prints a warning. The probe also checks early that the nodes can reach each other.

Before each probe, skate prints which node it's probing and against which node. During skate create node and skate upgrade node the transfer is given 10 seconds: if it hasn't finished by then it's abandoned with a warning suggesting skate cluster probe-transfer --node NAME at another time, the node keeps its previous rate (or none), and the command still succeeds. skate cluster probe-transfer has no time limit. Pass --skip-transfer-probe to skate create node or skate upgrade node to skip the probe entirely.

Nodes must reach each other over SSH on their peer_host and peer_port; if the home node can't reach the target, the move fails up front and the pod stays where it is. peer_port defaults to the node's port (or 22). Set it with skate create node --peer-port when skate reaches a node on a different port than other nodes do, eg through NAT, port forwarding or a bastion. The home node signs in to the target as the deploy user with the cluster's deploy key, through the skate you're running: the home node relays the login's challenge back over its connection to skate, which signs it once, so the key never leaves your machine (it can be in a key file or your ssh-agent) and no node's authorized_keys changes. skate can't tell which node that one login is really for: it trusts the home node to use it for the target it named. A pod's volumes can't move while another pod mounts the same PVC (eg the other replicas of a Deployment); then it stays on its home node, or fails if the home node can't take it.

If the home node is unreachable or gone, the pod isn't created anywhere, as with skate-local: a move needs the home node to send the data.

Ownership

Each PVC gets its own 1024-ID UID/GID block, chosen once, from a region of /etc/subuid and /etc/subgid that skate reserves on every node as skate-pinned:<base>:<size>. The region is the same on every node; skate create node or skate upgrade node picks it, above every node's existing entries, the first time and records it as pinned_id_region in the cluster config. Node setup fails, naming the entry, if an existing entry overlaps it.

A pod that mounts a PVC runs with --userns=auto:uidmapping=0:<base>:1024,gidmapping=0:<base>:1024, so it always gets the same host IDs and can keep writing the files earlier pods wrote, however many other pods start and stop in between. Pods granted host identity keep --userns=host, and pods without PVCs keep plain --userns=auto. A pod runs in one UID block, so the PVCs one pod mounts share it: a new PVC mounted with PVCs that already have a block takes their block. A pod that mounts existing PVCs with different blocks is refused, naming them.

Each node checks that a pod's skate.io/uid-base label is a block inside its skate-pinned region before playing it, so a manifest sent to a node directly can't map container root onto another host account.

Volumes

Each PVC is backed by its own podman volume, skate-<namespace>_<claim>, so the same claim name in two namespaces never shares data. Each Deployment replica gets its own, skate-<namespace>_<claim>_<replica>. Volumes carry the labels skate.io/namespace, skate.io/claim and skate.io/uid-base. A pod can only mount volumes of its own namespace.

Claims in DaemonSets and CronJobs aren't PVCs yet: they still mount a plain podman volume named after the claimName, with plain --userns=auto.

Commands

skate get pvc [-n <namespace>] [<name>]       # class, home node, UID base, size, implicit
skate describe pvc -n <namespace> <name>      # the same, and the pods that mount it
skate delete pvc -n <namespace> <name>
skate delete stale-copy -n <namespace> <name> --node <node>

skate get pvc and skate describe pvc list a PVC's stale copies, the volumes a move left on its old node, with their node and age. They're kept until you remove them with skate delete stale-copy, which deletes the volumes from that node only.

Deleting a pod or a Deployment, or scaling a Deployment down, never deletes volumes; scaling back up reuses the replicas' volumes. skate delete pvc removes the PVC's record on every node and its volumes on its home node and every node with a stale copy. It's refused while a pod mounts the PVC, naming the pod, and while the home node or a node with a stale copy is unreachable. Deleting a namespace deletes its PVCs and their volumes.

Exporting resources

skate get all lists every kind skate apply takes, except Pods: StorageClasses, PVCs, Secrets, ClusterIssuers, Services, Deployments, DaemonSets, CronJobs and Ingresses. With -o yaml it prints one document per resource, in the order apply needs them.

skate get all -A                                         # a table per kind, every namespace
skate get all -n web -o yaml                             # the stored records
skate get all -A -o yaml --neat --show-values > all.yaml # a full backup; asks for the sudo password
skate apply -f all.yaml                                  # restore it, here or on another cluster

By default, -o yaml and -o json print what skate stored, which apply changed: Secret names and references in the <name>.<namespace> form, skate.io/* labels and annotations, and metadata.generation. That output can't be applied again as is, and get all says so on stderr. --neat, on get all and on each kind, prints the manifests as you applied them instead (skate.io/ is reserved for skate, so all of it is removed), and skate apply -f accepts them again. It has no effect on nodes or tables.

Pods work differently, since skate stores the workload, not each of its pods:

skate get pods -n web -o yaml                  # each pod as it runs
skate get pod dpl-api-0 -n web -o yaml --neat # the manifest it was declared with

Without --neat, a pod's image, command, args and working directory come from the container runtime. Everything else is filled in from the pod's source: the Pod you applied, or the template of the Deployment, DaemonSet or CronJob that created it. With --neat, skate prints that source as a Pod named after the running one, without skate's additions. It fails for a pod whose source can't be found or no longer matches it, for example one left over from an older Deployment template, or one created before this skate version recorded template hashes, and never prints the running pod in its place.

Without --show-values, Secrets print as <redacted> and stderr says so. apply refuses a Secret holding <redacted> values, so it never overwrites real ones. Volume data is not exported, only the PVC objects.

skate apply also reads the kind: List that skate get <kind> -o yaml --neat prints, and it applies resources in kind order (StorageClasses and PVCs, then Secrets, ClusterIssuers, Services, workloads and Ingresses), whatever order the files list them in.

Developing

Mac

Native:

Install the targets:

rustup target add x86_64-unknown-linux-gnu
rustup target add aarch64-unknown-linux-gnu

Install the cross toolchains:

brew tap messense/macos-cross-toolchains
# install x86_64-unknown-linux-gnu toolchain
brew install x86_64-unknown-linux-gnu
# install aarch64-unknown-linux-gnu toolchain
brew install aarch64-unknown-linux-gnu

#add following to ~/.profile
PATH="${PATH}:/usr/local/Cellar/x86_64-unknown-linux-gnu/13.3.0.reinstall/bin/"
PATH="${PATH}:/usr/local/Cellar/aarch64-unknown-linux-gnu/13.3.0.reinstall/bin/"
# or whatever path brew puts the binaries in
make amd64
## or
make aarch64

Or just use https://github.com/cross-rs/cross

make amd64-cross
## or
make aarch64-cross

Note: you may need to run this to get cross to work, (issue):

docker run --privileged --rm tonistiigi/binfmt --install amd64

Ubuntu

# multipass image doesn't have much
sudo apt-get install -y gcc make libssl-dev pkg-config protobuf-compiler

Node access

Skate uses separate credentials for routine deployment and node administration. The cluster's default-user and default-key are the deploy SSH credentials; per-node user and key override them. admin-user and admin-key select the administrator SSH account and key, with optional per-node admin-user and admin-key overrides. Older configuration files remain valid. If no admin credential is configured, Skate falls back to the deploy credential and prints a warning.

Provision deploy public keys in the skate-deploy account's authorized_keys with this forced-command format (the node setup generates it):

restrict,command="skatelet gateway-client --id <name>" <key>

The gateway accepts one allowlisted request through a root-owned socket. No deploy-path operation ever runs caller-controlled code as the deploy UID. The skate namespace is admin-only; deploy credentials cannot apply, delete, or create jobs there.

Secrets read over the deploy path show every value as <redacted>. To read the values, skate get secret <name> -n <namespace> --show-values goes over the admin credential instead and needs the sudo password.

The sudo password

Admin operations (create node, upgrade node, apply/delete in the skate namespace, rollout, cluster reschedule) elevate with sudo -k -S on the admin account, so it needs a sudo password; NOPASSWD sudo is refused. By default Skate prompts for it on the terminal once per command and asks again if sudo rejects it.

For automation, the global --sudo-password-stdin flag reads the password instead as the first line of stdin:

printf '%s\n' "$PW" | skate create node --sudo-password-stdin --name node-1 ...

Stdin is read once, when the command starts, and anything after the first line is left for the command, so skate apply -f - takes the password line followed by the manifests. A password sudo rejects is an error, not a new prompt. Don't pass the password on the command line or in the environment.

sind create does this for its nodes. It configures the sind cluster with admin_user: skate, default_user: skate-deploy, and admin_key and default_key both set to --ssh-private-key (the deploy key comes from its .pub), gives each node --peer-port 22 (skate reaches the containers on mapped ports 2221, 2222, ..., while they reach each other on port 22), and pipes the sudo password to skate create node --sudo-password-stdin. The password is the first line of --sudo-password-file, or by default skate-test, the test-only password the sind images set.

Test clusters

For Linux builds on an Apple Silicon Mac, run make linux-build. This copies the current checkout, including uncommitted and untracked files, into the persistent skate-builder Lima VM, builds skate and skatelet there, and copies them to target/linux-aarch64/. Build only some binaries with hack/lima-build skatelet. It works from any worktree; builds share the VM's cache and run one at a time. Stop the VM with hack/lima-build stop; it keeps its Rust build cache for later runs.

To create a Lima test cluster, provide an SSH key and run:

SSH_PRIVATE_KEY=~/.ssh/id_ed25519 SSH_PUBLIC_KEY=~/.ssh/id_ed25519.pub DRIVER=lima DISTRO=ubuntu hack/clusterplz create
DRIVER=lima hack/clusterplz skate

skate prompts for the skateadmin sudo password on each node. It defaults to skate-test; set SKATEADMIN_PASSWORD to change it. Remove the cluster with DRIVER=lima hack/clusterplz remove.

End-to-end tests

tests/e2e_test.rs runs only when SKATE_E2E is set. It drives target/debug/skate against a running cluster, chosen with these environment variables:

Variable Default Meaning
SKATE_E2E_CONTEXT sind skate context to test
SKATE_E2E_NODES sind-node-1,sind-node-2 comma-separated node names
SKATE_E2E_CONFIG ~/.skate/config.yaml skate config file, passed as --skateconfig

To run it against a Lima cluster, write its config and point the tests at it:

SSH_PRIVATE_KEY=~/.ssh/id_ed25519 DRIVER=lima hack/clusterplz config > /tmp/skate-e2e.yaml
SSH_AUTH_SOCK= SKATE_E2E=1 SKATE_E2E_CONTEXT=clusterplz SKATE_E2E_NODES=node-1,node-2 \
  SKATE_E2E_CONFIG=/tmp/skate-e2e.yaml cargo test --test e2e_test -- --nocapture

clusterplz config prints the clusterplz context: skateadmin as the admin user, skate-deploy as the deploy user, and each node's host, peer host and subnet. The tests deploy with the deploy key and check nodes with skate node-shell, which uses the admin key and needs no sudo password.

Jelajahi proyek terkait

Memuat…