Hello,
I have a Pod which must run within hostNetwork
: https://hub.docker.com/r/dreamcat4/iscsi/
However, I want to have it available through the whole cluster - for all running containers.
My actual definition is:
---
kind: Service
apiVersion: v1
metadata:
name: iscsi-provisioning
spec:
selector:
app: iscsi-provisioning
type: NodePort
ports:
- name: iscsi
port: 3260
targetPort: 3260
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: iscsi-provisioning
spec:
replicas: 1
selector:
matchLabels:
app: iscsi-provisioning
template:
metadata:
labels:
app: iscsi-provisioning
spec:
hostNetwork: true
containers:
- name: iscsi-provisioning
image: dreamcat4/iscsi
ports:
- name: iscsi
containerPort: 3260
protocol: TCP
volumeMounts:
- name: iscsi
mountPath: /iscsi/targets
subPath: targets
securityContext:
privileged: true
volumes:
- name: iscsi
iscsi:
targetPortal: "172.9.10.254:3260"
iqn: "iqn.2004-04.com.qnap:ts-212:iscsi.mbr.d55afc"
lun: 1
fsType: ext4
readOnly: false
The result:
$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
iscsi-provisioning NodePort 10.105.92.149 <none> 3260:32417/TCP 3d
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 3d
# iscsiadm -m discovery -t sendtargets -p 10.105.92.149 | grep 200
192.168.253.51:3260,1 iqn.0000-00.dkr.iscsi:200
172.17.0.1:3260,1 iqn.0000-00.dkr.iscsi:200
10.244.2.0:3260,1 iqn.0000-00.dkr.iscsi:200
10.244.2.1:3260,1 iqn.0000-00.dkr.iscsi:200
What about the service-definition? Would you do it like above or is there a better definition? Should I use a fix IP for the service? I am looking forward to read your suggestions.
Thanks!