Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ deploy-kind:

@if [ "$(EXTENSIONS)" = "true" ]; then \
echo "🔧 Patching controller to enable extensions..."; \
kubectl patch statefulset agent-sandbox-controller \
kubectl patch deployment agent-sandbox-controller \
-n agent-sandbox-system \
-p '{"spec": {"template": {"spec": {"containers": [{"name": "agent-sandbox-controller", "args": ["--extensions=true"]}]}}}}'; \
fi
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent-sandbox-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func main() {
var pprofMutexProfileFraction int
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
flag.BoolVar(&enableLeaderElection, "leader-elect", true,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
flag.BoolVar(&extensions, "extensions", false, "Enable extensions controllers.")
Expand Down
13 changes: 10 additions & 3 deletions controllers/sandbox_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type SandboxReconciler struct {
//+kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=core,resources=persistentvolumeclaims,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=coordination.k8s.io,resources=leases,verbs=get;list;watch;create;update;patch

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down Expand Up @@ -289,6 +290,7 @@ func (r *SandboxReconciler) reconcileService(ctx context.Context, sandbox *sandb
}
} else {
log.Info("Found Service", "Service.Namespace", service.Namespace, "Service.Name", service.Name)
setServiceStatus(sandbox, service)
return service, nil
}

Expand Down Expand Up @@ -320,12 +322,17 @@ func (r *SandboxReconciler) reconcileService(ctx context.Context, sandbox *sandb
return nil, err
}

// TODO(barney-s) : hardcoded to svc.cluster.local which is the default. Need a way to change it.
sandbox.Status.ServiceFQDN = service.Name + "." + service.Namespace + ".svc.cluster.local"
sandbox.Status.Service = service.Name
setServiceStatus(sandbox, service)
return service, nil
}

// setServiceStatus updates the sandbox status with the service name and FQDN.
// TODO(barney-s): hardcoded to svc.cluster.local which is the default. Need a way to change it.
func setServiceStatus(sandbox *sandboxv1alpha1.Sandbox, service *corev1.Service) {
sandbox.Status.Service = service.Name
sandbox.Status.ServiceFQDN = service.Name + "." + service.Namespace + ".svc.cluster.local"
}

func (r *SandboxReconciler) reconcilePod(ctx context.Context, sandbox *sandboxv1alpha1.Sandbox, nameHash string) (*corev1.Pod, error) {
log := log.FromContext(ctx)

Expand Down
2 changes: 1 addition & 1 deletion examples/jupyterlab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Make sure the agent-sandbox controller is running before proceeding:

```bash
kubectl get pods -n agent-sandbox-system
# Should show agent-sandbox-controller-0 in Running state
# Should show agent-sandbox-controller-* in Running state
```

## Project Structure
Expand Down
6 changes: 3 additions & 3 deletions examples/python-runtime-sandbox/run-test-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ kubectl apply -f sandbox-python-kind.yaml
# Cleanup function
cleanup() {
echo "Cleaning up python-runtime and sandbox controller..."
kubectl delete --ignore-not-found -f sandbox-python-kind.yaml
kubectl delete --ignore-not-found statefulset agent-sandbox-controller -n agent-sandbox-system
kubectl delete --ignore-not-found crd sandboxes.agents.x-k8s.io
kubectl delete --timeout=10s --ignore-not-found -f sandbox-python-kind.yaml
kubectl delete --timeout=10s --ignore-not-found deployment agent-sandbox-controller -n agent-sandbox-system
kubectl delete --timeout=10s --ignore-not-found crd sandboxes.agents.x-k8s.io
echo "Deleting kind cluster..."
cd ../../
make delete-kind
Comment thread
antonipp marked this conversation as resolved.
Comment thread
antonipp marked this conversation as resolved.
Comment thread
antonipp marked this conversation as resolved.
Expand Down
1 change: 1 addition & 0 deletions extensions/controllers/sandboxclaim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type SandboxClaimReconciler struct {
//+kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch;update;patch
//+kubebuilder:rbac:groups=networking.k8s.io,resources=networkpolicies,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups="",resources=events,verbs=create;patch
//+kubebuilder:rbac:groups=coordination.k8s.io,resources=leases,verbs=get;list;watch;create;update;patch;delete

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down
5 changes: 3 additions & 2 deletions k8s/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@ spec:

---

kind: StatefulSet
kind: Deployment
Comment thread
janetkuo marked this conversation as resolved.
Comment thread
janetkuo marked this conversation as resolved.
apiVersion: apps/v1
Comment thread
antonipp marked this conversation as resolved.
metadata:
name: agent-sandbox-controller
namespace: agent-sandbox-system
labels:
app: agent-sandbox-controller
spec:
serviceName: agent-sandbox-controller
Comment thread
janetkuo marked this conversation as resolved.
replicas: 1
selector:
matchLabels:
Expand All @@ -70,3 +69,5 @@ spec:
containers:
- name: agent-sandbox-controller
image: ko://sigs.k8s.io/agent-sandbox/cmd/agent-sandbox-controller # placeholder value, replaced by deployment scripts
args:
- --leader-elect=true
12 changes: 12 additions & 0 deletions k8s/extensions-rbac.generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ rules:
- patch
- update
- watch
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- extensions.agents.x-k8s.io
resources:
Expand Down
4 changes: 2 additions & 2 deletions k8s/extensions.controller.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
---
kind: StatefulSet
kind: Deployment
apiVersion: apps/v1
metadata:
name: agent-sandbox-controller
namespace: agent-sandbox-system
labels:
app: agent-sandbox-controller
spec:
serviceName: agent-sandbox-controller
replicas: 1
selector:
matchLabels:
Expand All @@ -22,4 +21,5 @@ spec:
- name: agent-sandbox-controller
image: ko://sigs.k8s.io/agent-sandbox/cmd/agent-sandbox-controller # placeholder value, replaced by deployment scripts
args:
- "--leader-elect=true"
- "--extensions"
11 changes: 11 additions & 0 deletions k8s/rbac.generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,14 @@ rules:
- get
- patch
- update
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- get
- list
- patch
- update
- watch
2 changes: 1 addition & 1 deletion test/e2e/framework/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ func (cl *ClusterClient) validateAgentSandboxInstallation() error {
Name: "agent-sandbox-controller",
Namespace: ns.Name,
}
ctrl := &appsv1.StatefulSet{}
ctrl := &appsv1.Deployment{}
ctrl.Name = ctrlNN.Name
ctrl.Namespace = ctrlNN.Namespace
cl.MustExist(ctrl)
Expand Down