ポッドを静的 IP で構成しようとしています。multusでこれができることがわかりました。私の主な cni は calico で、いくつかの設定例は次のようになります。
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: dnsmasqconf-pv1
namespace: vt
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: ceph-rbd-sc
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: dnsmasq1
annotations:
k8s.v1.cni.cncf.io/networks: vt/macvlan
# "cni.projectcalico.org/ipAddrs": "[\"192.168.0.131\"]"
namespace: vt
labels:
name: dnsmasq1
# podIP: 192.168.0.131
spec:
# serviceName: "dnsmasq1"
replicas: 1
selector:
matchLabels:
name: dnsmasq1
template:
metadata:
labels:
name: dnsmasq1
spec:
hostNetwork: false
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
name: dnsmasq1
topologyKey: "kubernetes.io/hostname"
hostname: dnsmasq1
containers:
- name: dnsmasq1
image: jpillora/dnsmasq
ports:
- containerPort: 8080
imagePullPolicy: IfNotPresent
env:
- name: HTTP_USER
value: "user"
- name: HTTP_PASS
value: "password"
volumeMounts:
- mountPath: /mnt/config
name: dnsmasqconf-pv1
nodeSelector:
etiket: worker
dnsPolicy: "None"
dnsConfig:
nameservers:
- 8.8.8.8
volumes:
- name: dnsmasqconf-pv1
persistentVolumeClaim:
claimName: dnsmasqconf-pv1
「vt/macvlan」という注釈は次のようになります。
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
name: macvlan
namespace: vt
spec:
config: '{
"cniVersion": "0.3.1",
"type": "macvlan",
"master": "eth0",
"mode": "bridge",
"ipam": {
"type": "host-local",
"ranges": [
[ {
"subnet": "192.168.0.0/24",
"rangeStart": "192.168.0.131",
"rangeEnd": "192.168.0.131",
"gateway": "192.168.0.7"
} ]
]
}
}'
私もこのようなことを試しました:
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
name: eth0
namespace: vt
spec:
config: '{
"cniVersion": "0.3.1",
"type": "macvlan",
"master": "ens18",
"mode": "bridge",
"ipam": {
"type": "multus",
"subnet": "192.168.0.0/24",
"rangeStart": "192.168.0.131",
"rangeEnd": "192.168.0.131",
"routes": [
{ "dst": "0.0.0.0/0" }
],
"gateway": "192.168.0.7"
}
}'
ただし、構成に関係なく、ポッドは指定された ip で作成されません。この問題をできるだけ早く解決する必要があります。どうやってやるの?