Skip to content

Commit

Permalink
Merge branch 'improve-install'
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrox committed Jan 13, 2024
2 parents 1bb39ae + cb1c71a commit 86a461f
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 111 deletions.
35 changes: 14 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,8 @@ Once applied, check for `node` pod(s) in the `zeropod-system` namespace. If
everything worked it should be in status `Running`:

```bash
$ kubectl get pods -n zeropod-system
NAME READY STATUS RESTARTS AGE
zeropod-node-zr8k7 2/2 Running 0 35s
$ kubectl -n zeropod-system wait --for=condition=Ready pod -l app.kubernetes.io/name=zeropod-node
pod/zeropod-node-wgzrv condition met
```

Now you can create workloads which make use of zeropod.
Expand All @@ -186,6 +185,18 @@ match yours. In this case you need clone the repo and adjust the manifests in
`config/` accordingly. If your setup is common, a PR to add your configuration
adjustments would be most welcome.

### Uninstalling

To uninstall zeropod, you can apply the uninstall manifest to spawn a pod to
do the cleanup on all labelled zeropod nodes. After all the uninstall pods
have finished, we can delete all the manifests.

```bash
kubectl apply -k https://github.com/ctrox/zeropod/config/uninstall
kubectl -n zeropod-system wait --for=condition=Ready pod -l app.kubernetes.io/name=zeropod-node
kubectl delete -k https://github.com/ctrox/zeropod/config/production
```

## Configuration

A pod can make use of zeropod only if the `runtimeClassName` is set to
Expand Down Expand Up @@ -273,24 +284,6 @@ zeropod_restore_duration_seconds_count{container="nginx",namespace="default",pod
zeropod_running{container="nginx",namespace="default",pod="nginx"} 0
```

## TODO

- [x] Support more than 1 container in a zeropod
- [x] Support scaling more than 1 container in a zeropod (use-cases might be limited here)
- [x] Fix logs after restore
- [ ] Visibility into state (scaled down or up) from the outside
- [ ] k8s events?
- [x] Metrics
- [ ] Custom resource that syncs with a zeropod?
- [x] Create installer DaemonSet (runtime shim, containerd config, criu binary)
- [x] e2e testing
- [x] Scale down/up on demand instead of time based
- [x] technically scaling up on demand is now possible with exec. You can just exec a non-existing process.
- [x] Less configuration - try to detect the port(s) a contanier is listening on
- [x] Configurable installer (paths etc.)
- [ ] Create uninstaller
- [ ] Create issues instead of this list

## Development

For iterating on shim development it's recommended to use
Expand Down
13 changes: 0 additions & 13 deletions cmd/installer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import (
"log"
"os"
"os/exec"
"os/signal"
"path"
"path/filepath"
"syscall"
"time"

"github.com/containerd/containerd"
Expand Down Expand Up @@ -92,7 +90,6 @@ func main() {
}

log.Println("uninstaller completed")
// we exit after uninstall as this should be run as a one-time job
os.Exit(0)
}

Expand All @@ -115,16 +112,6 @@ func main() {
log.Println("installed runtimeClass")

log.Println("installer completed")

go func() {
for {
time.Sleep(time.Second)
}
}()

quitChannel := make(chan os.Signal, 1)
signal.Notify(quitChannel, syscall.SIGINT, syscall.SIGTERM)
<-quitChannel
}

func installCriu(ctx context.Context) error {
Expand Down
27 changes: 14 additions & 13 deletions config/base/node-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@ spec:
serviceAccountName: zeropod-node
nodeSelector:
zeropod.ctrox.dev/node: "true"
containers:
- name: manager
image: manager
imagePullPolicy: IfNotPresent
ports:
- name: metrics
containerPort: 8080
volumeMounts:
- mountPath: /run/zeropod
name: zeropod-run
initContainers:
- name: installer
image: installer
args: []
Expand All @@ -42,6 +33,16 @@ spec:
name: systemd-run
- mountPath: /etc/criu
name: criu-etc
containers:
- name: manager
image: manager
imagePullPolicy: IfNotPresent
ports:
- name: metrics
containerPort: 8080
volumeMounts:
- mountPath: /run/zeropod
name: zeropod-run
tolerations:
- key: kubernetes.io/arch
operator: Equal
Expand All @@ -54,12 +55,12 @@ spec:
- name: containerd-run
hostPath:
path: /run/containerd
- name: zeropod-run
hostPath:
path: /run/zeropod
- name: zeropod-opt
hostPath:
path: /opt/zeropod
- name: zeropod-run
hostPath:
path: /run/zeropod
- name: systemd-run
hostPath:
path: /run/systemd
Expand Down
2 changes: 1 addition & 1 deletion config/gke/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ patchesStrategicMerge:
patches:
- patch: |-
- op: add
path: /spec/template/spec/containers/1/args/-
path: /spec/template/spec/initContainers/0/args/-
value: -host-opt-path=/var/lib/toolbox/zeropod
target:
kind: DaemonSet
2 changes: 1 addition & 1 deletion config/k3s/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ patchesStrategicMerge:
patches:
- patch: |-
- op: add
path: /spec/template/spec/containers/1/args/-
path: /spec/template/spec/initContainers/0/args/-
value: -runtime=k3s
target:
kind: DaemonSet
2 changes: 1 addition & 1 deletion config/production/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ images:
patches:
- patch: |-
- op: add
path: /spec/template/spec/containers/1/args/-
path: /spec/template/spec/initContainers/0/args/-
value: -criu-image=ghcr.io/ctrox/zeropod-criu:v3.19
target:
kind: DaemonSet
2 changes: 1 addition & 1 deletion config/rke2/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ patchesStrategicMerge:
patches:
- patch: |-
- op: add
path: /spec/template/spec/containers/1/args/-
path: /spec/template/spec/initContainers/0/args/-
value: -runtime=rke2
target:
kind: DaemonSet
24 changes: 19 additions & 5 deletions config/uninstall/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
resources:
- uninstaller.yaml
images:
- name: installer
newName: ghcr.io/ctrox/zeropod-installer
newTag: dev
- ../production
patches:
- patch: |-
- op: add
path: /spec/template/spec/initContainers/0/args/-
value: -uninstall
- op: replace
path: /spec/template/spec/initContainers/0/volumeMounts/2
value:
mountPath: /opt
name: opt
- op: replace
path: /spec/template/spec/volumes/2
value:
hostPath:
path: /opt
name: opt
target:
kind: DaemonSet
55 changes: 0 additions & 55 deletions config/uninstall/uninstaller.yaml

This file was deleted.

0 comments on commit 86a461f

Please sign in to comment.