#!/usr/bin/env bash set -euo pipefail # kubeclaw quickstart: install CRDs + deploy controller on Docker Desktop Kubernetes # Prerequisites: Docker Desktop with Kubernetes enabled, kubectl pointing to docker-desktop echo "=== kubeclaw Quickstart ===" echo "" # 1. Verify cluster access echo "→ Checking cluster connection..." kubectl cluster-info --request-timeout=5s > /dev/null 2>&1 || { echo "ERROR: Cannot reach Kubernetes cluster." echo "Make sure Docker Desktop has Kubernetes enabled (Settings → Kubernetes → Enable Kubernetes)" exit 1 } echo " ✓ Cluster reachable ($(kubectl config current-context))" # 2. Install CRDs echo "" echo "→ Installing CRDs..." for crd in config/crd/bases/*.yaml; do kubectl apply -f "$crd" done echo " ✓ CRDs installed" # Wait for CRDs to register sleep 2 # 3. Verify CRDs are ready echo "" echo "→ Verifying CRDs..." kubectl get crd | grep kubeclaw.scoble.me | awk '{print " " $1}' # 4. Create namespace echo "" echo "→ Creating scobleclaw namespace..." kubectl create namespace scobleclaw --dry-run=client -o yaml | kubectl apply -f - echo " ✓ Namespace ready" # 5. Deploy controller echo "" echo "→ Deploying kubeclaw controller..." kubectl apply -f config/rbac/role.yaml 2>/dev/null || { # Generate minimal RBAC if role.yaml doesn't exist kubectl apply -f - <<'RBAC' apiVersion: v1 kind: ServiceAccount metadata: name: kubeclaw-controller namespace: scobleclaw --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: kubeclaw-controller rules: - apiGroups: ["kubeclaw.scoble.me"] resources: ["*"] verbs: ["*"] - apiGroups: [""] resources: ["pods", "configmaps", "serviceaccounts"] verbs: ["*"] - apiGroups: [""] resources: ["secrets"] verbs: ["get", "list", "watch"] - apiGroups: ["apps"] resources: ["deployments"] verbs: ["*"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: kubeclaw-controller roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: kubeclaw-controller subjects: - kind: ServiceAccount name: kubeclaw-controller namespace: scobleclaw RBAC } kubectl apply -f - <<'DEPLOYMENT' apiVersion: v1 kind: ConfigMap metadata: name: kubeclaw-config namespace: scobleclaw data: config.yaml: | logLevel: info --- apiVersion: apps/v1 kind: Deployment metadata: name: kubeclaw-controller namespace: scobleclaw labels: app: kubeclaw spec: replicas: 1 selector: matchLabels: app: kubeclaw template: metadata: labels: app: kubeclaw spec: serviceAccountName: kubeclaw-controller containers: - name: manager image: ghcr.io/sscoble/kubeclaw:latest imagePullPolicy: IfNotPresent command: ["/manager"] args: - --health-probe-bind-address=:8081 - --metrics-bind-address=:8080 ports: - containerPort: 8080 name: metrics - containerPort: 8081 name: health resources: requests: cpu: 100m memory: 128Mi limits: cpu: 500m memory: 256Mi livenessProbe: httpGet: path: /healthz port: health readinessProbe: httpGet: path: /readyz port: health DEPLOYMENT echo " ✓ Controller deployed" # 6. Wait for controller echo "" echo "→ Waiting for controller to start..." kubectl wait --for=condition=available deployment/kubeclaw-controller -n scobleclaw --timeout=60s 2>/dev/null || { echo " (controller may still be starting — check with 'kubectl get pods -n scobleclaw')" } # 7. Apply samples echo "" echo "→ Installing sample resources..." for sample in config/samples/0*.yaml; do echo " Applying $sample..." kubectl apply -f "$sample" -n scobleclaw 2>/dev/null || kubectl apply -f "$sample" done echo "" echo "=== Quickstart Complete ===" echo "" echo "Check status:" echo " kubectl get agents -n scobleclaw" echo " kubectl get workflowtemplates" echo " kubectl get compliancepolicies" echo "" echo "View controller logs:" echo " kubectl logs -n scobleclaw deployment/kubeclaw-controller"