Skip to content

Commit 81c2ace

Browse files
authored
Merge pull request #52 from aifoundry-org/manifests
Manifests
2 parents a21e550 + f68e645 commit 81c2ace

File tree

22 files changed

+828
-65
lines changed

22 files changed

+828
-65
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ $(BINDIR):
2727
@mkdir -p $@
2828

2929
$(CONTROLLER): $(BINDIR)
30-
@go build -o $@
30+
@go build -o $@ ./cmd/
3131

3232
link: $(CONTROLLER) $(CONTROLLER_GENERIC)
3333

chart/Chart.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v2
2+
name: oxide-controller
3+
version: 0.1.0
4+
description: Deploys the oxide controller

chart/templates/namespace.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: {{ .Values.namespace }}

chart/templates/rbac.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
name: oxide-controller
5+
namespace: {{ .Values.namespace }}
6+
rules:
7+
- apiGroups: [""]
8+
resources: ["secrets"]
9+
resourceNames: ["{{ .Values.secretName }}"]
10+
verbs: ["get", "update", "patch", "create"]
11+
---
12+
apiVersion: rbac.authorization.k8s.io/v1
13+
kind: RoleBinding
14+
metadata:
15+
name: oxide-controller
16+
namespace: {{ .Values.namespace }}
17+
subjects:
18+
- kind: ServiceAccount
19+
name: oxide-controller
20+
namespace: {{ .Values.namespace }}
21+
roleRef:
22+
kind: Role
23+
name: oxide-controller
24+
apiGroup: rbac.authorization.k8s.io

chart/templates/service.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: oxide-controller
5+
namespace: {{ .Values.namespace }}
6+
spec:
7+
selector:
8+
app: oxide-controller
9+
ports:
10+
- name: http
11+
port: 80
12+
targetPort: {{ .Values.image.port }}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: oxide-controller
5+
namespace: {{ .Values.namespace }}

chart/templates/statefulset.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
apiVersion: apps/v1
2+
kind: StatefulSet
3+
metadata:
4+
name: oxide-controller
5+
namespace: {{ .Values.namespace }}
6+
spec:
7+
serviceName: oxide-controller
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: oxide-controller
12+
template:
13+
metadata:
14+
labels:
15+
app: oxide-controller
16+
spec:
17+
serviceAccountName: oxide-controller
18+
priorityClassName: system-cluster-critical
19+
tolerations:
20+
- key: "node-role.kubernetes.io/control-plane"
21+
operator: "Exists"
22+
effect: "NoSchedule"
23+
- key: "node-role.kubernetes.io/master"
24+
operator: "Exists"
25+
effect: "NoSchedule"
26+
- key: "node.kubernetes.io/not-ready"
27+
operator: "Exists"
28+
effect: "NoExecute"
29+
tolerationSeconds: 300
30+
- key: "node.kubernetes.io/unreachable"
31+
operator: "Exists"
32+
effect: "NoExecute"
33+
tolerationSeconds: 300
34+
containers:
35+
- name: controller
36+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
37+
args: --no-pivot=true
38+
ports:
39+
- containerPort: {{ .Values.image.port }}
40+
env:
41+
- name: SECRET_NAME
42+
value: "{{ .Values.secretName }}"

chart/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace: oxide-controller-system
2+
secretName: oxide-controller-secret
3+
image:
4+
repository: aifoundryorg/oxide-controller
5+
tag: latest
6+
port: 8080

cmd/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package main
2+
3+
func main() {
4+
Execute()
5+
}

cmd/root.go

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package cmd
1+
package main
22

33
import (
44
"context"
@@ -50,7 +50,7 @@ func rootCmd() (*cobra.Command, error) {
5050
workerExternalIP bool
5151
controlPlaneExternalIP bool
5252
controlLoopMins int
53-
runOnce bool
53+
noPivot bool
5454
controlPlaneImageBlocksize int
5555
workerImageBlocksize int
5656
imageParallelism int
@@ -62,6 +62,7 @@ func rootCmd() (*cobra.Command, error) {
6262
tailscaleAPIKey string
6363
tailscaleTag string
6464
tailscaleTailnet string
65+
controllerOCIImage string
6566

6667
logger = log.New()
6768
)
@@ -165,6 +166,7 @@ func rootCmd() (*cobra.Command, error) {
165166
kubeconfigOverwrite,
166167
tailscaleAPIKey,
167168
tailscaleTailnet,
169+
controllerOCIImage,
168170
)
169171
// we perform 2 execution loops of the cluster execute function:
170172
// - the first one is to create the cluster and get the kubeconfig
@@ -180,11 +182,27 @@ func rootCmd() (*cobra.Command, error) {
180182
}
181183
}
182184

183-
if runOnce {
184-
logentry.Infof("Run once mode enabled, exiting after first run")
185+
// Several possibilities:
186+
// 1- we are running in the cluster, in which case we should just keep running
187+
// 2- we are running locally, in which case we should load the helm charts onto the cluster and exit
188+
// 3- we are running locally, and we have nopivot, in which case we should just keep running
189+
//
190+
// load the helm charts onto the cluster and pivot the controller to the cluster,
191+
// then shut down this server.
192+
//
193+
// Unless nopivot is true, in which case we do not pivot
194+
// and just keep running locally.
195+
if !noPivot {
196+
logentry.Infof("Loading helm charts and pivoting to run on the cluster")
197+
if err := c.LoadHelmCharts(ctx); err != nil {
198+
return fmt.Errorf("failed to load helm charts onto the cluster: %v", err)
199+
}
185200
return nil
186201
}
187202

203+
logentry.Infof("Not pivoting to run on the cluster, continuing to run locally")
204+
205+
// we had noPivot, so keep running
188206
// start each control loop
189207
var (
190208
wg sync.WaitGroup
@@ -260,7 +278,8 @@ func rootCmd() (*cobra.Command, error) {
260278
cmd.Flags().BoolVar(&controlPlaneExternalIP, "control-plane-external-ip", true, "Whether or not to assign an ephemeral public IP to the control plane nodes, needed to access cluster from outside sled, as well as for debugging")
261279
cmd.Flags().IntVarP(&verbose, "verbose", "v", 0, "set log level, 0 is info, 1 is debug, 2 is trace")
262280
cmd.Flags().StringVar(&address, "address", ":8080", "Address to bind the server to")
263-
cmd.Flags().BoolVar(&runOnce, "runonce", false, "Run the server once and then exit, do not run a long-running control loop for checking the controller or listening for API calls")
281+
cmd.Flags().BoolVar(&noPivot, "no-pivot", false, "Do not pivot this controller to run on the cluster itself after bringing the cluster up, instead continue long-running here")
282+
cmd.Flags().StringVar(&controllerOCIImage, "controller-oci-image", "aifoundryorg/oxide-controller:latest", "OCI image to use for the controller")
264283
cmd.Flags().IntVar(&controlLoopMins, "control-loop-mins", 5, "How often to run the control loop, in minutes")
265284
cmd.Flags().IntVar(&imageParallelism, "image-parallelism", 1, "How many parallel threads to use for uploading images to the sled")
266285
cmd.Flags().StringVar(&tailscaleAuthKey, "tailscale-auth-key", "", "Tailscale auth key to use for authentication, if none provided, will not join a tailnet; if starts with 'file:' then will read the key from the file")

0 commit comments

Comments
 (0)