Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
c941467
make proxy
davidepasquero1 Jun 28, 2025
9fe0f43
make proxy
davidepasquero1 Jun 28, 2025
de35fd9
ok dietro proxy
davidepasquero1 Jun 28, 2025
f96d69c
Implement leader election in the agent
google-labs-jules[bot] Jun 29, 2025
6b879cf
feat: Introduce independent deployment for agent
google-labs-jules[bot] Jun 29, 2025
ba06b55
chart funzionante con deploy agent
davidepasquero1 Jul 1, 2025
efd0430
Refactor: Remove agent pod management from controller
google-labs-jules[bot] Jul 1, 2025
149fdfa
resolve bug ippool
davidepasquero1 Jul 1, 2025
dd8c304
remove agent managment
davidepasquero1 Jul 1, 2025
e684361
remove agent managment from controlller
davidepasquero1 Jul 1, 2025
5fd5564
aggiinte rbac x webhook
davidepasquero1 Jul 1, 2025
df75d3c
Fix: Use agent's namespace for leader election
google-labs-jules[bot] Jul 1, 2025
4966f69
Refactor: Standardize labels in agent ClusterRole
google-labs-jules[bot] Jul 1, 2025
b33d5bc
Fix: Correct webhook certificate SAN by providing namespace
google-labs-jules[bot] Jul 2, 2025
bdc0ccd
Refactor: Simplify agent ClusterRole and ClusterRoleBinding names
google-labs-jules[bot] Jul 2, 2025
865eca3
Feat: Controller dynamically updates agent deployment for NAD attachment
google-labs-jules[bot] Jul 2, 2025
4bfde2d
Fix: Resolve Go build errors in ippool controller
google-labs-jules[bot] Jul 2, 2025
7a321bb
Fix: Resolve metav1 redeclaration in ippool controller
google-labs-jules[bot] Jul 2, 2025
d119208
Feat: Controller updates agent's IPPOOL_REF env var dynamically
google-labs-jules[bot] Jul 2, 2025
94fcbde
Fix: Remove unused envVarUpdated variable in ippool controller
google-labs-jules[bot] Jul 2, 2025
3c199ac
Fix: Resolve agent container location and deployment update permission
google-labs-jules[bot] Jul 3, 2025
2617522
Fix: Resolve undefined AgentContainerNameDefault in ippool controller…
google-labs-jules[bot] Jul 3, 2025
2257af7
Feat: Enable agent to configure static IP on Multus interface
google-labs-jules[bot] Jul 3, 2025
d9a64c2
Fix: Correct misplaced import block in pkg/agent/agent.go
google-labs-jules[bot] Jul 3, 2025
72a3825
Fix: Ensure agent DHCP cache is synced before serving requests
google-labs-jules[bot] Jul 3, 2025
e68d4c0
Fix: Resolve multiple build errors and logic in agent's ippool contro…
google-labs-jules[bot] Jul 3, 2025
72021ad
Fix: Resolve build errors and logic for agent ippool lease sync
google-labs-jules[bot] Jul 3, 2025
034d913
feat: Configure agent for multiple IPPools via controller
google-labs-jules[bot] Jul 5, 2025
dff2607
fix: Remove unused import from pkg/config/context.go
google-labs-jules[bot] Jul 5, 2025
44dd87d
fix: Correct build errors in ippool controller
google-labs-jules[bot] Jul 5, 2025
ab5c1f2
fix: Resolve undefined k8serrors and ensure correct error handling
google-labs-jules[bot] Jul 5, 2025
2cca870
fix: Correct agent build error by adjusting DHCPAllocator call
google-labs-jules[bot] Jul 5, 2025
e6c951c
fix: Remove obsolete flag definitions in agent CLI
google-labs-jules[bot] Jul 5, 2025
14c7019
fix: Prevent controller panic by removing eager initial reconciliation
google-labs-jules[bot] Jul 5, 2025
99a295a
fix: Prevent controller panic by removing eager initial reconciliation
google-labs-jules[bot] Jul 5, 2025
218b1ad
Fix(ippool): Ensure IPPoolCache is synced before listing
google-labs-jules[bot] Jul 5, 2025
39f5ae7
Fix(ippool): Use ippoolCache.HasSynced for cache readiness check
google-labs-jules[bot] Jul 5, 2025
03a7175
Fix(ippool): Use controller's informer for HasSynced check
google-labs-jules[bot] Jul 5, 2025
9f443b7
Diag(ippool): Add detailed logging for cache sync
google-labs-jules[bot] Jul 5, 2025
d3e76ad
Implement multi-interface DHCP server in agent
google-labs-jules[bot] Jul 6, 2025
8a25ef7
Fix: Correct syntax error in pkg/dhcp/dhcp.go
google-labs-jules[bot] Jul 6, 2025
6862c26
Fix(ippool): Prevent nil pointer dereference in reconcileAgentDeployment
google-labs-jules[bot] Jul 6, 2025
29e5406
Fix(ippool): Use informer store directly to prevent nil pointer panic
google-labs-jules[bot] Jul 6, 2025
0b2fd5e
Fix: Prevent DHCP servers from shutting down prematurely
google-labs-jules[bot] Jul 6, 2025
dd21395
Fix: Ensure DHCP agent loads and syncs leases from IPPool CRD
google-labs-jules[bot] Jul 7, 2025
0c2d1d2
Fix: Add missing imports in pkg/agent/agent.go
google-labs-jules[bot] Jul 7, 2025
a049f21
DHCP leases across multiple network interfaces.
davide-pasquero Jul 8, 2025
7da1677
feat: enhance DHCP server logging for UDP communications
google-labs-jules[bot] Jul 9, 2025
82006d8
fix: Ensure I process the initial IPPool state correctly on leader ch…
google-labs-jules[bot] Jul 11, 2025
086d05a
fix: Prevent panic on context cancellation during agent shutdown
google-labs-jules[bot] Jul 11, 2025
d388fec
Update SCCcredentials
davidepasquero Jul 25, 2025
8af510e
docs: remove architecture image
davidepasquero Sep 16, 2025
32db5f7
Delete SCCcredentials
davidepasquero Jul 25, 2025
abfedff
Merge pull request #13 from davidepasquero/codex/analyze-last-49-comm…
davidepasquero Sep 16, 2025
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
29 changes: 28 additions & 1 deletion Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,33 @@ FROM registry.suse.com/bci/golang:1.23
ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH

RUN zypper -n install tar gzip bash git docker less file curl wget
# Proxy configuration
ARG http_proxy
ARG https_proxy
ARG no_proxy

ENV http_proxy $http_proxy
ENV https_proxy $https_proxy
ENV no_proxy $no_proxy

# Configure zypper proxy if https_proxy is set
RUN if [ -n "$https_proxy" ]; then \
PROXY_URL_NO_SCHEME=$(echo "$https_proxy" | sed -e 's#http://##g' -e 's#https://##g'); \
PROXY_HOST=$(echo "$PROXY_URL_NO_SCHEME" | cut -d':' -f1); \
PROXY_PORT=$(echo "$PROXY_URL_NO_SCHEME" | cut -d':' -f2 | cut -d'/' -f1); \
echo "proxy.enabled = true" >> /etc/zypp/zypp.conf; \
echo "proxy.host = $PROXY_HOST" >> /etc/zypp/zypp.conf; \
echo "proxy.port = $PROXY_PORT" >> /etc/zypp/zypp.conf; \
echo "proxy.protocol = http" >> /etc/zypp/zypp.conf; \
echo "Zypper proxy configured to $PROXY_HOST:$PROXY_PORT"; \
else \
echo "No https_proxy set, skipping zypper proxy configuration."; \
fi

# Copy SUSE credentials
COPY SCCcredentials /etc/zypp/credentials.d/SCCcredentials

RUN zypper ref -s && zypper -n update && zypper -n install tar gzip bash git docker less file curl wget

RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.63.4

Expand All @@ -23,3 +49,4 @@ WORKDIR ${DAPPER_SOURCE}

ENTRYPOINT ["./scripts/entry"]
CMD ["ci"]

22 changes: 22 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ If release name contains chart name it will be used as a full name.
{{- end }}
{{- end }}

{{/*
Return the agent service account name
*/}}
{{- define "harvester-vm-dhcp-controller.agentServiceAccountName" -}}
{{- if .Values.agent.serviceAccount.create }}
{{- default (printf "%s-agent" (include "harvester-vm-dhcp-controller.fullname" .)) .Values.agent.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.agent.serviceAccount.name }}
{{- end }}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
Expand Down Expand Up @@ -76,3 +87,14 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Return the appropriate apiVersion for rbac.
*/}}
{{- define "harvester-vm-dhcp-controller.rbac.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1" }}
{{- print "rbac.authorization.k8s.io/v1" }}
{{- else }}
{{- print "v1" }}
{{- end }}
{{- end -}}
24 changes: 24 additions & 0 deletions chart/templates/agent-clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if .Values.agent.enabled -}}
{{- if .Values.agent.rbac.create -}}
apiVersion: {{ template "harvester-vm-dhcp-controller.rbac.apiVersion" . }}
kind: ClusterRole
metadata:
name: {{ .Release.Name }}-dhcp-agent-clusterrole
labels:
{{- include "harvester-vm-dhcp-controller.labels" . | nindent 4 }}
app.kubernetes.io/component: agent # Override component to agent
rules:
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: [""] # Core API group
resources: ["configmaps"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: [""] # Core API group
resources: ["events"]
verbs: ["create", "patch"]
- apiGroups: ["network.harvesterhci.io"]
resources: ["ippools"]
verbs: ["get", "list", "watch"]
{{- end -}}
{{- end -}}
19 changes: 19 additions & 0 deletions chart/templates/agent-clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if .Values.agent.enabled -}}
{{- if .Values.agent.rbac.create -}}
apiVersion: {{ template "harvester-vm-dhcp-controller.rbac.apiVersion" . }}
kind: ClusterRoleBinding
metadata:
name: {{ .Release.Name }}-dhcp-agent-binding
labels:
{{- include "harvester-vm-dhcp-controller.labels" . | nindent 4 }}
app.kubernetes.io/component: agent
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ .Release.Name }}-dhcp-agent-clusterrole
subjects:
- kind: ServiceAccount
name: {{ include "harvester-vm-dhcp-controller.agentServiceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
{{- end }}
73 changes: 73 additions & 0 deletions chart/templates/agent-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{- if .Values.agent.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "harvester-vm-dhcp-controller.fullname" . }}-agent
labels:
{{- include "harvester-vm-dhcp-controller.labels" . | nindent 4 }}
app.kubernetes.io/component: agent
spec:
replicas: {{ .Values.agent.replicaCount | default 2 }}
selector:
matchLabels:
{{- include "harvester-vm-dhcp-controller.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: agent
template:
metadata:
labels:
{{- include "harvester-vm-dhcp-controller.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: agent
spec:
serviceAccountName: {{ include "harvester-vm-dhcp-controller.agentServiceAccountName" . }}
securityContext:
{{- toYaml .Values.agent.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}-agent
securityContext:
{{- $mergedSecContext := .Values.agent.securityContext | default dict -}}
{{- $capabilities := $mergedSecContext.capabilities | default dict -}}
{{- $addCapabilities := $capabilities.add | default list -}}
{{- if not (has "NET_ADMIN" $addCapabilities) -}}
{{- $addCapabilities = append $addCapabilities "NET_ADMIN" -}}
{{- end -}}
{{- $_ := set $capabilities "add" $addCapabilities -}}
{{- $_ := set $mergedSecContext "capabilities" $capabilities -}}
{{- toYaml $mergedSecContext | nindent 12 }}
image: "{{ .Values.agent.image.repository }}:{{ .Values.agent.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.agent.image.pullPolicy }}
args:
- {{ printf "--name=%s-agent" (include "harvester-vm-dhcp-controller.fullname" .) }}
# - {{ printf "--namespace=%s" .Release.Namespace }} # Rimosso
- "--kubeconfig=/etc/kubeconfig"
- {{ printf "--no-leader-election=%t" (.Values.agent.noLeaderElection | default false) }}
# Removed --nic argument, controller will manage interfaces via annotations and AGENT_NETWORK_CONFIGS
ports:
- name: metrics
containerPort: 8080
protocol: TCP
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
# IPPOOL_REF is removed, replaced by AGENT_NETWORK_CONFIGS and IPPOOL_REFS_JSON
# These will be populated by the controller. Default to empty JSON arrays.
- name: AGENT_NETWORK_CONFIGS
value: "[]"
- name: IPPOOL_REFS_JSON
value: "[]"
resources:
{{- toYaml .Values.agent.resources | nindent 12 }}
{{- with .Values.agent.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.agent.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.agent.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}
15 changes: 15 additions & 0 deletions chart/templates/agent-serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.agent.enabled -}}
{{- if .Values.agent.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "harvester-vm-dhcp-controller.agentServiceAccountName" . }}
labels:
{{- include "harvester-vm-dhcp-controller.labels" . | nindent 4 }}
app.kubernetes.io/component: agent
{{- with .Values.agent.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
19 changes: 13 additions & 6 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ spec:
args:
- --name
- {{ include "harvester-vm-dhcp-controller.fullname" . }}
- --namespace
- {{ .Release.Namespace }}
- --image
- "{{ .Values.agent.image.repository }}:{{ .Values.agent.image.tag | default .Chart.AppVersion }}"
- --service-account-name
- {{ include "harvester-vm-dhcp-controller.serviceAccountName" . }}-agent
# --image # Rimosso: l'agent ora ha il suo deployment
# - "{{ .Values.agent.image.repository }}:{{ .Values.agent.image.tag | default .Chart.AppVersion }}" # Rimosso
# --service-account-name # Rimosso
# - {{ include "harvester-vm-dhcp-controller.serviceAccountName" . }}-agent # Rimosso
ports:
- name: metrics
protocol: TCP
Expand All @@ -49,6 +47,15 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: AGENT_DEPLOYMENT_NAME
value: {{ include "harvester-vm-dhcp-controller.fullname" . }}-agent
- name: AGENT_CONTAINER_NAME
value: {{ .Chart.Name }}-agent
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
Expand Down
30 changes: 29 additions & 1 deletion chart/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ rules:
resources: [ "ippools", "virtualmachinenetworkconfigs" ]
verbs: [ "*" ]
- apiGroups: [ "" ]
resources: [ "nodes", "secrets" ]
resources: [ "nodes" ]
verbs: [ "watch", "list" ]
- apiGroups: [ "" ]
resources: [ "secrets" ]
verbs: [ "get", "watch", "list", "create", "update", "patch" ]
- apiGroups: [ "k8s.cni.cncf.io" ]
resources: [ "network-attachment-definitions" ]
verbs: [ "get", "watch", "list" ]
Expand Down Expand Up @@ -108,6 +111,30 @@ subjects:
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "harvester-vm-dhcp-controller.name" . }}-deployment-manager
namespace: {{ .Release.Namespace }}
rules:
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["get", "list", "watch", "patch", "update"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "harvester-vm-dhcp-controller.name" . }}-manage-agent-deployments
namespace: {{ .Release.Namespace }}
subjects:
- kind: ServiceAccount
name: {{ include "harvester-vm-dhcp-controller.serviceAccountName" . }} # Controller's SA
namespace: {{ .Release.Namespace }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "harvester-vm-dhcp-controller.name" . }}-deployment-manager
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "harvester-vm-dhcp-controller.name" . }}-lease-manager
namespace: kube-system
Expand Down Expand Up @@ -184,3 +211,4 @@ subjects:
- kind: ServiceAccount
name: {{ include "harvester-vm-dhcp-controller.serviceAccountName" . }}-webhook
namespace: {{ .Release.Namespace }}

70 changes: 47 additions & 23 deletions chart/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,64 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "harvester-vm-dhcp-controller.serviceAccountName" . }}
name: {{ include "harvester-vm-dhcp-controller.serviceAccountName" . }} # SA per il Controller
labels:
{{- include "harvester-vm-dhcp-controller.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount | default true }}
{{- end -}}

{{- /*
Logica per determinare se creare il SA del Webhook e con quali valori.
*/}}
{{- $createWebhookSA := false -}}
{{- $webhookSAName := printf "%s-webhook" (include "harvester-vm-dhcp-controller.fullname" .) -}}
{{- $webhookSAAnnotations := dict -}}
{{- $webhookSAAutomount := .Values.serviceAccount.automount | default true -}}

{{- if .Values.webhook -}}
{{- $webhookEnabled := true -}}
{{- if hasKey .Values.webhook "enabled" -}}
{{- $webhookEnabled = .Values.webhook.enabled -}}
{{- end -}}

{{- if $webhookEnabled -}}
{{- $webhookSpecificSACreate := true -}}
{{- if and (hasKey .Values.webhook "serviceAccount") (hasKey .Values.webhook.serviceAccount "create") -}}
{{- $webhookSpecificSACreate = .Values.webhook.serviceAccount.create -}}
{{- end -}}

{{- if and .Values.serviceAccount.create $webhookSpecificSACreate -}}
{{- $createWebhookSA = true -}}
{{- if and (hasKey .Values.webhook "serviceAccount") .Values.webhook.serviceAccount -}}
{{- if .Values.webhook.serviceAccount.name -}}
{{- $webhookSAName = .Values.webhook.serviceAccount.name -}}
{{- end -}}
{{- if .Values.webhook.serviceAccount.annotations -}}
{{- $webhookSAAnnotations = .Values.webhook.serviceAccount.annotations -}}
{{- end -}}
{{- if hasKey .Values.webhook.serviceAccount "automount" -}}
{{- $webhookSAAutomount = .Values.webhook.serviceAccount.automount -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{- if $createWebhookSA -}}
---
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "harvester-vm-dhcp-controller.serviceAccountName" . }}-agent
labels:
{{- include "harvester-vm-dhcp-controller.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
---
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "harvester-vm-dhcp-controller.serviceAccountName" . }}-webhook
name: {{ $webhookSAName }}
labels:
{{- include "harvester-vm-dhcp-controller.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
{{- include "harvester-vm-dhcp-webhook.labels" . | nindent 4 }}
{{- with $webhookSAAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
automountServiceAccountToken: {{ $webhookSAAutomount }}
{{- end -}}
Loading