OpenShift 4 之通过命令创建Service Mesh环境

本文使用命令行方式在OpenShift 4上创建Service Mesh运行环境,然后进行验证。
图形化方式创建Service Mesh运行环境可参见《OpenShift 4 之Service Mesh入门》。

创建ServiceMesh环境

  1. 确认可以查到Service Mesh相关的Operator。
$ oc get packagemanifests {servicemeshoperator,kiali-ossm,jaeger-product,elasticsearch-operator} -n openshift-marketplace
NAME                     CATALOG             AGE
servicemeshoperator      Red Hat Operators   17d
kiali-ossm               Red Hat Operators   17d
jaeger-product           Red Hat Operators   17d
elasticsearch-operator   Red Hat Operators   17d
  1. 创建Service Mesh Operator的订阅(会自动创建其依赖的其它Operator)。
$ cat > service-mesh-subscription.yaml << EOF
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: servicemeshoperator
  namespace: openshift-operators
spec:
  channel: "1.0"
  name: servicemeshoperator
  source: redhat-operators
  sourceNamespace: openshift-marketplace
EOF
$ oc apply -f service-mesh-subscription.yaml
$ oc get sub -n openshift-operators
NAME                                                                PACKAGE                  SOURCE             CHANNEL
elasticsearch-operator-4.2-redhat-operators-openshift-marketplace   elasticsearch-operator   redhat-operators   4.2
jaeger-product-stable-redhat-operators-openshift-marketplace        jaeger-product           redhat-operators   stable
kiali-ossm-stable-redhat-operators-openshift-marketplace            kiali-ossm               redhat-operators   stable
servicemeshoperator                                                 servicemeshoperator      redhat-operators   1.0```
  1. 创建运行istio资源的项目。
$ oc new-project istio-system
  1. 创建istio的ServiceMeshControlPlane。
$ cat > istio-installation.yaml << EOF
---
apiVersion: maistra.io/v1
kind: ServiceMeshControlPlane
metadata:
  name: basic-install
spec:
  istio:
    gateways:
      istio-egressgateway:
        autoscaleEnabled: false
      istio-ingressgateway:
        autoscaleEnabled: false
    mixer:
      policy:
        autoscaleEnabled: false
      telemetry:
        autoscaleEnabled: false
    pilot:
      autoscaleEnabled: false
      traceSampling: 100
    kiali:
      enabled: true
    grafana:
      enabled: true
    tracing:
      enabled: true
      jaeger:
        template: all-in-one
EOF
$ oc create -n istio-system -f istio-installation.yaml
servicemeshcontrolplane.maistra.io/basic-install created
$ oc get smcp -n istio-system
NAME            READY
basic-install   
  1. 查看Pod的创建进度,最后会有如下12个Pod。
$ oc get pod
NAME                                     READY   STATUS    RESTARTS   AGE
grafana-56f9c8b54-7wblr                  2/2     Running   0          2m28s
istio-citadel-5d5c8687df-t4v98           1/1     Running   0          5m44s
istio-egressgateway-6686d54c49-9s28v     1/1     Running   0          3m8s
istio-galley-86d9d8d49b-dztvj            1/1     Running   0          4m55s
istio-ingressgateway-56857ff7f7-vfg6k    1/1     Running   0          3m8s
istio-pilot-fb5f78c44-blz2x              2/2     Running   0          3m55s
istio-policy-56c77687b5-7zj8w            2/2     Running   0          4m32s
istio-sidecar-injector-b6985f8b8-slhxr   1/1     Running   0          2m54s
istio-telemetry-775f7df579-8fgnt         2/2     Running   0          4m32s
jaeger-57776787bc-8chlt                  2/2     Running   0          4m58s
kiali-967b567b6-crdch                    1/1     Running   0          98s
prometheus-6488c47945-d2wwr              2/2     Running   0          5m26s
  1. 创建istio的ServiceMeshMemberRoll。
$ cat > servicemeshmemberroll-default.yaml << EOF
---
apiVersion: maistra.io/v1
kind: ServiceMeshMemberRoll
metadata:
  name: default
  namespace: istio-system
spec:
  members:
    # a list of projects joined into the service mesh
    - default
EOF
$ oc create -n istio-system -f servicemeshmemberroll-default.yaml
servicemeshmemberroll.maistra.io/default created

至此,一个基于Istio的Service Mesh环境就准备好了。在配合Istio应用使用的时候,我们可以修改ServiceMeshMemberRoll的配置,将Istio应用所在的项目加到member中即可。

发布了54 篇原创文章 · 获赞 0 · 访问量 1105

猜你喜欢

转载自blog.csdn.net/weixin_43902588/article/details/103757837