ServiceMesh 1.0 を OpenShift 4 にインストールする

Red Hatの中山です。先日、OpenShift Service Mesh 1.0 が GA になったので、インストールしてみます。

blog.openshift.com

OpenShift 4の他のOperatorと同様、ServiceMeshはOperatorHubからインストールするのですが、今回は、すべてコマンドラインからインストールします。ドキュメントには、GUIからインストールする方法が書かれているので、GUIがお好きな方はドキュメントを読みながらGUIからインストールしてみてください。

docs.openshift.com

インストールコマンドの実行には、cluster-adminかそれ相当の権限が必要になります。

最初に、ServiceMeshのオペレーターをインストールします。CatalogSourceConfigとSubscriptionを作ります。

cat <<EOF | oc apply -f -
apiVersion: operators.coreos.com/v1
kind: CatalogSourceConfig
metadata:
  name: ci-operators
  namespace: openshift-marketplace
spec:
  targetNamespace: openshift-operators
  packages: elasticsearch-operator,jaeger-product,kiali-ossm,servicemeshoperator
  source: redhat-operators
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: elasticsearch-operator
  namespace: openshift-operators
spec:
  channel: preview
  name: elasticsearch-operator
  source: ci-operators
  sourceNamespace: openshift-operators
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: jaeger-product
  namespace: openshift-operators
spec:
  channel: stable
  name: jaeger-product
  source: ci-operators
  sourceNamespace: openshift-operators
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: kiali-ossm
  namespace: openshift-operators
spec:
  channel: stable
  name: kiali-ossm
  source: ci-operators
  sourceNamespace: openshift-operators
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: servicemeshoperator
  namespace: openshift-operators
spec:
  channel: "1.0"
  name: servicemeshoperator
  source: ci-operators
  sourceNamespace: openshift-operators
EOF

openshift-operatorsプロジェクトで、以下の4つのPodがRunning状態になればOKです。ElasticSearch、Jaeger、Kialiは不要なんですけど...と言う方も、現時点(1.0GA時)では、Operatorのインストールが必要になります。ただ、Operatorのインストールが必要となるだけで、これら3つが不要な場合には、実際のインスタンスをインストールする必要はありません。実際、今回の手順では、ElasticSearch、Jaeger、Kialiはインストールしません。

$ oc get pod -n openshift-operators
NAME                                      READY   STATUS    RESTARTS   AGE
elasticsearch-operator-54b656cbb4-9bwdn   1/1     Running   0          11m
istio-operator-64f969655b-vwnks           1/1     Running   0          11m
jaeger-operator-55f47cccbc-x99rn          1/1     Running   0          11m
kiali-operator-865b8cfc7b-kbm69           1/1     Running   0          11m

Opeeratorのインストールが終れば、あとは簡単、ServiceMeshControlPlaneを作成して、istioのPodをデプロイするだけです。今回は、最小限で以下の構成にします。

oc new-project istio-system

cat <<EOF | oc apply -f -
apiVersion: maistra.io/v1
kind: ServiceMeshControlPlane
metadata:
  name: minimal-multitenant-cni-install
  namespace: istio-system
spec:
  istio:
    global:
      multitenant: true
      proxy:
        autoInject: disabled
      omitSidecarInjectorConfigMap: true
      disablePolicyChecks: false
      defaultPodDisruptionBudget:
        enabled: false
    istio_cni:
      enabled: true
    gateways:
      istio-ingressgateway:
        autoscaleEnabled: false
        type: LoadBalancer
      istio-egressgateway:
        enabled: false
      cluster-local-gateway:
        autoscaleEnabled: false
        enabled: true
        labels:
          app: cluster-local-gateway
          istio: cluster-local-gateway
        ports:
          - name: status-port
            port: 15020
          - name: http2
            port: 80
            targetPort: 8080
          - name: https
            port: 443
    mixer:
      enabled: false
      policy:
        enabled: false
      telemetry:
        enabled: false
    pilot:
      autoscaleEnabled: false
      sidecar: false
    kiali:
      enabled: false
    tracing:
      enabled: false
    prometheus:
      enabled: false
    grafana:
      enabled: false
    sidecarInjectorWebhook:
      enabled: false
EOF

上記の構成でデプロイすると、istio-systemプロジェクトに、以下のPodが起動します。

$ oc get pod -n istio-system 
NAME                                     READY   STATUS    RESTARTS   AGE
cluster-local-gateway-76cc6d67c4-z8g86   1/1     Running   0          67m
istio-citadel-7cb44f4bb-khr2d            1/1     Running   0          68m
istio-galley-75599dbc67-k9z2c            1/1     Running   0          68m
istio-ingressgateway-769c96c46f-lp9zf    1/1     Running   0          67m
istio-pilot-7c7dd546f9-mfnzq             1/1     Running   0          67m

以上で、インストールが終わりました。OpenShift 4共通に言えることですが、Operatorを利用しているため、インストールはとても簡単です。Istio定番のbookinfoアプリなんかで遊んでみてください。ドキュメントもあります。

docs.openshift.com

ちょっとした注意点として、ドキュメントにも書かれていますが、OpenShiftでServiceMeshをインストールする場合、CNIプラグインを有効化しているので、ServiceMeshMemberRollというリソースを作ってcontrol planeとsidecarのやり取りを許可する必要があります。例えば、bookinfoプロジェクトを利用する場合は、以下の設定を忘れずに。

cat <<EOF | oc apply -f -
apiVersion: maistra.io/v1
kind: ServiceMeshMemberRoll
metadata:
  name: default
  namespace: istio-system
spec:
  members:
  - bookinfo
EOF

最後に、今回の記事は説明が少ないし、「やってみた(だけ)」記事だし、ServiceMeshインストールして、この後どうすれば良いか分からない、という方!次回の「OpenShift Meetup Tokyo」は、Service Mesh & Serverless 特集です。ぜひ、参加して更なる深い話を聞いたり、参加者で情報を共有しましょう。

openshift.connpass.com

* 各記事は著者の見解によるものでありその所属組織を代表する公式なものではありません。その内容については非公式見解を含みます。