<p>I'm trying to deploy a DHCP server in a pod on my Kubernetes cluster.
I've created the following resources:</p>

<blockquote>
  <p>$ cat dhcpd-deployment.yaml </p>
</blockquote>

<pre><code>
kind: Deployment
metadata:
  name: dhcpd
  namespace: kube-mngt
spec:
  selector:
    matchLabels:
      app: dhcpd
  replicas: 1
  template:
    metadata:
      labels:
        app: dhcpd
    spec:
      nodeSelector:
        kubernetes.io/hostname: neo1
      containers:
      - name: dhcpd
        image: 10.0.100.1:5000/dhcpd:latest
        volumeMounts:
        - name: dhcpd-config
          mountPath: /etc/dhcp
      volumes:
        - name: dhcpd-config
          persistentVolumeClaim:
            claimName: dhcpd-config-volume-claim
</code></pre>

<blockquote>
  <p>$ kubectl create -f dhcpd-deployment.yaml</p>
  
  <p>$ cat dhcpd-service.yaml</p>
</blockquote>

<pre><code>apiVersion: v1

kind: Service
metadata:
  name: dhcpd
  namespace: kube-mngt
spec:
  selector:
    app: dhcpd
  ports:
  - name: dhcp
    protocol: UDP
    port: 67
    targetPort: 67
</code></pre>

<blockquote>
  <p>$ kubectl create -f dhcpd-service.yaml</p>
</blockquote>

<p>Everything is created successfully, pod and service but unfortunately, the DHCPD pod does not receive any packet on UDP port 67.</p>

<p>Did I miss something?</p>

jpm
<p>I've found the solution to make the dhcpd pod working well.
The example below is to server a external network outside of the k8s service network (clusterIPs).
The dhcp configuration is like following:</p>

<pre><code>include "/etc/dhcp/dhcpd-options.conf";

subnet 192.168.0.0 netmask 255.255.0.0 {}

# management network
subnet 10.0.0.0 netmask 255.255.0.0 {
  option routers 10.0.255.254;
  option broadcast-address 10.0.255.255;
  next-server 10.0.100.6;
  include "/etc/dhcp/lease-bmc.conf";
  include "/etc/dhcp/lease-node.conf";
}
</code></pre>

<p>The k8s service is as following:</p>

<p>$ cat dhcpd-service.yaml</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: dhcpd
  namespace: kube-mngt
spec:
  selector:
    app: dhcpd
  ports:
  - protocol: UDP
    port: 67
    targetPort: 67
  externalIPs:
  - 10.0.100.5
</code></pre>

<p>Then, configure the switch (interface vlan X) to specify an helper-address that point the the dhcp server (in our case, 10.0.100.5)</p>

<pre><code>interface Vlan1
 ip address 10.0.255.254 255.255.0.0 secondary
 ip address 10.0.0.1 255.255.0.0
 ip helper-address 10.0.100.5
!
</code></pre>
