Red Hatã§OpenShiftã®ãµãã¼ãããã¦ããid:nekopã§ããOpenShift Advent Calendar 2019ã®2æ¥ç®ã®ã¨ã³ããªã§ãã
OpenShift Service Meshã¯Istioã®è£½åçã§ãããé常ã®Istioãã»ããã¢ããããã¨ãã¨å°ãæ§æãç°ãªããIstio CNIã¨ãããã®ãå©ç¨ããã¦ãã¾ãã
Istioã¯ãã©ãã£ãã¯ãã¤ã³ã¿ã¼ã»ãããã¦Sidecar proxyã¸æµãããã«iptablesã®ã«ã¼ã«ãå©ç¨ãã¦ãã¾ãããã®iptablesã®ã«ã¼ã«ãã©ã®ããã«é©ç¨ããããã¨ããã¨ããã§ãããé常ã®ã»ããã¢ããã§ã¯Init containerãSidecar proxyã¨å ±ã«ã¢ããªã±ã¼ã·ã§ã³ã®Podã¸Injectããã¦å©ç¨ããã¾ãããã®Init containerã¯iptablesãå©ç¨ãããããNET_ADMIN capabilityã許å¯ããã¦ããç¹æ¨©ã³ã³ãã(privileged, è¦ã¯root権é)ã¨ãã¦è¨å®ãããå¿ è¦ãããã¾ããããããç¹æ¨©ã³ã³ããã許å¯ãã¦ãã¾ãã¨ãã¢ããªã±ã¼ã·ã§ã³ã®ãã横ã«ã»ãã¥ãªãã£ã¬ãã«ã®å¼±ãã³ã³ãããé ç½®ããããã¨ã«ãªãã¾ãããç¹æ¨©ã³ã³ããèµ·åã許å¯ããã¦ãããµã¼ãã¹ã¢ã«ã¦ã³ããæµç¨ãã¦ä»ã®æªæã®ããç¹æ¨©ã³ã³ãããèµ·åãã¦ããããã§ãã¦ãã¾ã£ããããã®ã§åé¿ãããã¨ããã§ããããã§å©ç¨ãããã®ãIstio CNIã¨ããCNIãã©ã°ã¤ã³ã§ããIstio CNIã§ã¯ç¹æ¨©Init contaienrã§ã¯ãªãCNIã®ä»çµã¿å ããiptablesã®ã«ã¼ã«é©ç¨ãè¡ã£ã¦ãã¾ãã
ãããOpenShift 4.2ä¸ã§ã©ã®ããã«æ§æããã¦ãããè¦ã¦ããããã¨æãã¾ãããã®ä¾ã§ã¯test-istio
ã¨ããããã¸ã§ã¯ãã対象ã«è¦ã¦ããã¾ãã
OpenShift Service Meshã§ã¯ServiceMeshMemberRollsã¨ãããªã½ã¼ã¹ã«Istioã使ãããã¸ã§ã¯ããè¨è¿°ããã¨ã»ããã¢ãããå®è¡ããã¾ãã
$ oc get -n istio-system servicemeshmemberrolls.maistra.io NAME MEMBERS default [knative-serving test-knative test-istio]
OpenShift 4ã§ã¯multus-cniã¨ããCNIãã©ã°ã¤ã³ãæè»ã«é¸æã§ããCNIã¡ã¿ãã©ã°ã¤ã³ãæ¨æºã¨ãªã£ã¦ãããä¸è¨è¨å®ãè¡ãã¨Multusã®NetworkAttachmentDefinitionã¨ãããªã½ã¼ã¹ãããã¸ã§ã¯ãã«ä½æãããistio-cniãæå¹åããã¾ããNetworkAttachmentDefinitionã®ä¸èº«ã¯å©ç¨ããCNIã®ååã ãæå®ããã¦ãããã®ã§ãã
$ oc get network-attachment-definitions.k8s.cni.cncf.io --all-namespaces NAMESPACE NAME AGE knative-serving istio-cni 23m test-istio istio-cni 23m test-knative istio-cni 32d $ oc get -n test-istio network-attachment-definitions.k8s.cni.cncf.io istio-cni -o yaml apiVersion: k8s.cni.cncf.io/v1 kind: NetworkAttachmentDefinition metadata: generation: 1 name: istio-cni namespace: test-istio
ãã®è¨å®ã¯ã©ãã«ç´ã¥ãã¦ãããã¨ããã¨ãOpenShift Service Meshã«å«ã¾ããDaemonSetãåãã¼ãã®multusè¨å®ãã£ã¬ã¯ããªã«CNIè¨å®ãã¡ã¤ã«ãé ç½®ãã¦ãã¦ããã®ååãæå®ãã¦ãã¾ãã
$ oc set volumes -n openshift-operators ds/istio-node daemonsets/istio-node host path /opt/multus/bin as cni-bin-dir mounted at /host/opt/cni/bin host path /etc/cni as etc-cni-dir mounted at /host/etc/cni/
ãã®DaemonSetã«ãã£ã¦åãã¹ãã«ä»¥ä¸ã®ãã¡ã¤ã«ç¾¤ãé ç½®ããã¦ãã¾ãã
/etc/cni/multus/net.d/istio-cni.conf /etc/cni/multus/net.d/istio-cni.kubeconfig /opt/cni/bin/istio-cni /opt/cni/bin/istio-iptables.sh
å®éã®CNIè¨å®å 容ã¯ä»¥ä¸ã®ããã«ãªã£ã¦ãã¾ãã
$ oc debug node/node01 # chroot /host # cat /etc/cni/multus/net.d/istio-cni.conf { "cniVersion": "0.3.0", "name": "istio-cni", "type": "istio-cni", "log_level": "info", "kubernetes": { "kubeconfig": "/etc/cni/multus/net.d/istio-cni.kubeconfig", "cni_bin_dir": "/opt/multus/bin", "iptables_script": "istio-iptables.sh", "exclude_namespaces": [ "openshift-operators" ] } }
OpenShift Service Meshã§ã¯ããã®ããã«DaemonSetã§Multusã«istio-cniè¨å®ãé ç½®ãMultusã®NetworkAttachmentDefinitionã§æå¹åããã¨ããä»çµã¿ãå©ç¨ãã¦ç¹æ¨©ã³ã³ãããå©ç¨ããªããããå®å ¨ãªIstioã®ã»ããã¢ãããå®ç¾ãã¦ãã¾ãã