Skip to content

Commit 912209e

Browse files
committed
add lima integration step to doc
Signed-off-by: olalekan odukoya <[email protected]>
1 parent 0d641dd commit 912209e

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

docs/content/setup/integrations.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,116 @@ them to OpenFGA queries.
5959

6060
!!! info "Third Party Solutions"
6161
A third-party example of such a webhook would be Platform Mesh's [rebac-authz-webhook](https://github.com/platform-mesh/rebac-authz-webhook).
62+
63+
## Lima
64+
You can run kcp inside a [Lima](https://github.com/lima-vm/lima)-managed VM, which makes it portable across macOS, Linux, and Windows (via WSL2). This setup gives you a disposable kcp control plane that integrates smoothly with your host kubectl.
65+
66+
Create a Lima template for kcp and save the following as `kcp.yaml`:
67+
```yaml
68+
minimumLimaVersion: 1.1.0
69+
70+
base: template://_images/ubuntu-lts
71+
72+
mounts: []
73+
74+
containerd:
75+
system: false
76+
user: false
77+
78+
provision:
79+
- mode: system
80+
script: |
81+
#!/bin/bash
82+
set -eux -o pipefail
83+
command -v kcp >/dev/null 2>&1 && exit 0
84+
85+
export DEBIAN_FRONTEND=noninteractive
86+
apt-get update
87+
apt-get install -y curl wget
88+
89+
KCP_VERSION=$(curl -s https://api.github.com/repos/kcp-dev/kcp/releases/latest | grep tag_name | cut -d '"' -f 4)
90+
KCP_VERSION_NO_V=${KCP_VERSION#v}
91+
92+
wget https://github.com/kcp-dev/kcp/releases/download/${KCP_VERSION}/kcp_${KCP_VERSION_NO_V}_linux_arm64.tar.gz
93+
tar -xzf kcp_${KCP_VERSION_NO_V}_linux_arm64.tar.gz
94+
mv bin/kcp /usr/local/bin/
95+
chmod +x /usr/local/bin/kcp
96+
rm -f kcp_${KCP_VERSION_NO_V}_linux_arm64.tar.gz
97+
98+
mkdir -p /var/.kcp/
99+
sudo chmod 755 /var/.kcp
100+
101+
cat > /etc/systemd/system/kcp.service << EOF
102+
[Unit]
103+
Description=kcp server
104+
After=network.target
105+
106+
[Service]
107+
Type=simple
108+
User=root
109+
ExecStart=/usr/local/bin/kcp start --root-directory=/var/.kcp/ --bind-address=127.0.0.1
110+
Restart=on-failure
111+
StandardOutput=journal
112+
StandardError=journal
113+
114+
[Install]
115+
WantedBy=multi-user.target
116+
EOF
117+
118+
systemctl daemon-reload
119+
systemctl enable kcp
120+
systemctl start kcp
121+
122+
probes:
123+
- script: |
124+
#!/bin/bash
125+
set -eux -o pipefail
126+
if ! timeout 120s bash -c "until curl -f -s --cacert /var/.kcp/apiserver.crt https://127.0.0.1:6443/readyz >/dev/null; do sleep 3; done"; then
127+
echo >&2 "kcp is not ready yet"
128+
exit 1
129+
fi
130+
hint: |
131+
The kcp control plane is not ready yet.
132+
Check the kcp logs with "limactl shell kcp sudo journalctl -f" or "tail -f /var/log/kcp.log"
133+
134+
copyToHost:
135+
- guest: "/var/.kcp/admin.kubeconfig"
136+
host: "{{ '{{.Dir}}' }}/copied-from-guest/kubeconfig.yaml"
137+
deleteOnStop: true
138+
139+
message: |
140+
To run `kubectl` on the host (assumes kubectl is installed), run:
141+
------
142+
export KUBECONFIG="{{ '{{.Dir}}' }}/copied-from-guest/kubeconfig.yaml"
143+
kubectl get workspaces
144+
------
145+
146+
```
147+
Initialize the VM
148+
```sh
149+
limactl create --name=kcp ./kcp.yaml
150+
```
151+
152+
Start the VM
153+
```sh
154+
limactl start kcp --vm-type=qemu
155+
```
156+
!!! info
157+
On macOS, Lima may default to vz (Apple Virtualization), while on Linux it defaults to qemu, and on Windows to wsl2. If you want consistency across environments, you can explicitly pass --vm-type=qemu when starting the VM.
158+
159+
Export the KCP kubeconfig
160+
```sh
161+
export KUBECONFIG="/Users/<user>/.lima/kcp/copied-from-guest/kubeconfig.yaml"
162+
```
163+
164+
Verify API resources
165+
```sh
166+
kubectl api-resources | grep kcp
167+
```
168+
You should see kcp-specific resources such as:
169+
```sh
170+
workspaces ws tenancy.kcp.io/v1alpha1 false Workspace
171+
logicalclusters core.kcp.io/v1alpha1 false LogicalCluster
172+
...
173+
```
174+

0 commit comments

Comments
 (0)