File size: 7,429 Bytes
3b70664
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#+TITLE: Migrating to Nekomata from Kubernetes
#+AUTHOR: SnapKitty Systems
#+DATE: 2026
#+OPTIONS: toc:2 num:t

* Overview

This document describes the migration path from a Kubernetes-based
deployment to Nekomata. The migration is incremental: you can run
Nekomata alongside an existing Kubernetes cluster, migrating workloads
one at a time.

* Concept Mapping

| Kubernetes | Nekomata | Notes |
|------------|----------|-------|
| Pod | =container-spec= | Nekomata does not have the Pod/Container distinction. One spec = one container. |
| Deployment | =(define-container ...)= + evolutionary population | The Deployment's replica count becomes a =(replica-constraint lo hi)= |
| Service | Network policy + port mapping | Nekomata routes traffic via the regex-math policy layer |
| Namespace | Container name prefix convention | =api-*= and =db-*= are namespaces encoded in names |
| ConfigMap | Lisp =defvar= or env alist in spec | Config is code. It lives in the image. |
| Secret | Lisp =defvar= in sealed image section | Sealed via image encryption, not Kubernetes RBAC |
| NetworkPolicy | Kleene algebra policy expression | More expressive than K8s NetworkPolicy |
| HorizontalPodAutoscaler | =replica-constraint= + evolutionary loop | Autoscaling is a fitness function, not a YAML object |
| CronJob | Lisp timer in the eval loop | =sb-ext:schedule-timer= or similar |
| PersistentVolume | Volume spec in =container-spec= | Maps directly to Docker bind mount |
| Ingress | Routing expert + port forwarding | Nekomata does not have an Ingress object |
| RBAC | Security expert + Kleene policy | Roles are regex patterns over container identities |

* Step 1: Inventory Your Workloads

Before migrating, generate a complete inventory of your Kubernetes
workloads:

#+BEGIN_SRC shell
# Export all Deployments as YAML
kubectl get deployments --all-namespaces -o yaml > k8s-deployments.yaml

# Export all Services
kubectl get services --all-namespaces -o yaml > k8s-services.yaml

# Export all NetworkPolicies
kubectl get networkpolicies --all-namespaces -o yaml > k8s-netpolicies.yaml
#+END_SRC

* Step 2: Translate Deployments to Container Specs

For each Kubernetes Deployment, create a Nekomata =define-container=:

** Kubernetes Deployment (YAML):
#+BEGIN_SRC yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-server
spec:
  replicas: 3
  selector:
    matchLabels:
      app: api-server
  template:
    metadata:
      labels:
        app: api-server
    spec:
      containers:
      - name: api-server
        image: mycompany/api:v2.1.0
        ports:
        - containerPort: 8080
        env:
        - name: DB_HOST
          value: "postgres:5432"
        - name: LOG_LEVEL
          value: "info"
#+END_SRC

** Nekomata Container Spec (Lisp):
#+BEGIN_SRC lisp
(define-container api-server
  :image "mycompany/api:v2.1.0"
  :ports '((8080 . 8080))
  :env '((:DB_HOST . "postgres:5432")
         (:LOG_LEVEL . "info"))
  :restart-policy :always)

;; Replica count as an evolutionary constraint
(push (replica-constraint 2 5) *active-constraints*)
#+END_SRC

The replica count becomes a constraint that the evolutionary optimizer
satisfies. Instead of specifying =replicas: 3= as a static value, you
specify a range (2 to 5) and let the optimizer find the right count
based on observed CPU and memory utilization.

* Step 3: Translate NetworkPolicies

** Kubernetes NetworkPolicy:
#+BEGIN_SRC yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: api-to-db
spec:
  podSelector:
    matchLabels:
      app: postgres
  ingress:
  - from:
    - podSelector:
        matchLabels:
          app: api-server
    ports:
    - protocol: TCP
      port: 5432
#+END_SRC

** Nekomata Policy:
#+BEGIN_SRC lisp
(define-policy api-to-db
  :from (re-concat (re-literal "api-") (re-star re-any))
  :to   (re-literal "postgres")
  :port (re-literal "5432")
  :op   :allow)
#+END_SRC

Note that the Nekomata policy is more expressive: it matches any
container whose name starts with "api-", not just ones with the
label =app: api-server=. You can add the label restriction by using
a more precise pattern.

* Step 4: Translate RBAC

Kubernetes RBAC is a role/binding system. Nekomata does not have
RBAC objects -- access control is encoded directly in Kleene algebra
policies over container identities.

The general mapping: a Kubernetes Role with rules for resource
=pods= and verb =list= maps to a Nekomata monitoring policy that allows
the monitoring container to inspect all containers.

* Step 5: Run Nekomata Alongside Kubernetes

During migration, run Nekomata as an additional Docker-based system
alongside your Kubernetes cluster:

1. Start the Nekomata daemon on a dedicated node outside the k8s cluster
2. Migrate non-critical services first (monitoring, batch jobs, dev environments)
3. Use Nekomata as the primary scheduler for new services
4. Gradually migrate production services as confidence increases

Nekomata and Kubernetes share the same container runtime (containerd/Docker).
Migrated containers run the same images. Only the orchestration layer changes.

* Step 6: Sunset the Kubernetes Control Plane

Once all workloads are migrated:

#+BEGIN_SRC shell
# Drain all nodes (stop scheduling new pods)
kubectl drain --all --ignore-daemonsets

# Delete the cluster (if using a managed service)
# ... provider-specific command

# Stop local etcd and control plane components
systemctl stop kube-apiserver kube-controller-manager kube-scheduler
#+END_SRC

You have recovered: ~200ms control plane latency, ~500MB memory for
etcd, ~1GB for the control plane components, and the full-time salary
of whoever was maintaining the Kubernetes cluster.

* Migration Checklist

- [ ] Inventory all Deployments, StatefulSets, DaemonSets
- [ ] Translate each workload to a =define-container= form
- [ ] Translate NetworkPolicies to Kleene algebra policies
- [ ] Translate RBAC to Nekomata security expert policies
- [ ] Set up Nekomata evolutionary constraints (replica ranges, CPU budgets)
- [ ] Run both systems in parallel for at least one week
- [ ] Verify telemetry and health checks match between systems
- [ ] Migrate production traffic to Nekomata
- [ ] Decommission Kubernetes control plane
- [ ] Save first WORM-sealed Nekomata image checkpoint

* What You Lose

Be honest about the tradeoffs:

- *Kubernetes ecosystem*: Helm charts, Operators, the CNCF tool zoo do not exist for Nekomata.
- *Multi-cluster federation*: Nekomata is single-node or manually federated.
- *Managed service*: No EKS/GKE/AKS equivalent. You operate the Nekomata daemon.
- *kubectl*: The neko CLI is simpler but not as feature-rich yet.

* What You Gain

- *Zero YAML*: All infrastructure is Lisp code. It evaluates. It composes.
- *Hot-swap*: Update any function without restarting the daemon.
- *Evolutionary optimization*: Container specs improve automatically.
- *LLM intent compilation*: Natural language to machine code.
- *Formal policy verification*: Prove your network policies are correct before applying them.
- *Image persistence*: The entire state is a single file. Restart is instant.
- *10x simpler control plane*: One Lisp image vs. etcd + apiserver + controller-manager + scheduler.