我正在尝试在我的Kubernetes集群上的Pod中部署DHCP服务器。 我创建了以下资源:
$ cat dhcpd-deployment.yaml
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
$ kubectl create -f dhcpd-deployment.yaml
$ cat dhcpd-service.yaml
apiVersion: v1
kind: Service
metadata:
name: dhcpd
namespace: kube-mngt
spec:
selector:
app: dhcpd
ports:
- name: dhcp
protocol: UDP
port: 67
targetPort: 67
$ kubectl create -f dhcpd-service.yaml
一切都可以成功创建,pod和服务,但不幸的是,DHCPD pod无法在UDP端口67上接收任何数据包。
我错过了什么吗?
答案 0 :(得分:1)
我找到了使dhcpd pod正常工作的解决方案。 下面的示例是为k8s服务网络(clusterIP)之外的外部网络提供服务器。 dhcp配置如下:
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";
}
k8s服务如下:
$ cat dhcpd-service.yaml
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
然后,配置交换机(接口vlan X)以指定指向dhcp服务器的助手地址(在本例中为10.0.100.5)
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
!