kubernetes上的模式注册表,可公开访问

e4eetjau  于 2021-06-07  发布在  Kafka
关注(0)|答案(2)|浏览(337)

我在azure上有一个三节点kubernetes集群,有三个kafka代理和一个zookeeper示例。kafka代理和zookeeper可以通过部署相应的服务(负载平衡器)公开访问。
现在我正在部署一个模式注册表,我希望它可以从kubernetes集群外部访问。我遵循与以前相同的步骤,但无法从kubernetes集群外部访问schema registry api。如果我从docker容器中 curl 模式注册表,一切正常,因此我假设模式注册表正常运行。以下是我的模式注册表yamls描述符:
架构注册表部署:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: schema-registry
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: schema-registry
    spec:
      containers:
      - env:
        - name: SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL
          value: zookeeper-cluster-ip:2181
        - name: SCHEMA_REGISTRY_HOST_NAME
          value: registry-0.schema.default.svc.cluster.local
        - name: SCHEMA_REGISTRY_LISTENERS
          value: http://0.0.0.0:8081
        name: schema-registry
        image: confluentinc/cp-schema-registry:5.0.1
        ports:
        - containerPort: 8081
      restartPolicy: Always

架构注册表服务:

apiVersion: v1
kind: Service
metadata:
  name: schema-registry
  labels:
    name: schema-registry
spec:
  ports:
  - port: 8081
  selector:
    name: schema-registry
  type: LoadBalancer

部署服务后,生成公共ip:

kubectl get services
NAME              TYPE           CLUSTER-IP     EXTERNAL-IP    PORT(S)                      AGE
schema-registry   LoadBalancer   X.X.X.X.       X.X.X.X.       8081:30921/TCP               13m

,所以我跑了

curl -X GET -i -H "Content-Type: application/vnd.schemaregistry.v1+json" http://X.X.X.X:8081/subjects

但没有回应。在容器中,我从curl命令得到一个响应。
我希望从集群外部访问模式注册表的原因是我们希望从nifi集群访问它。
有可能吗?

jchrr9hc

jchrr9hc1#

我以前也遇到过同样的问题,我用selector/app解决了这个问题。

Deployment:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  namespace:***
  name: schema-registry
  labels:
    app: schema-registry
spec:
  replicas: 1
  selector:
    matchLabels:
      app: schema-registry
  template:
    metadata:
      labels:
        app: schema-registry
    spec:
      containers:
      - name: schema-registry
        image: confluentinc/cp-schema-registry:5.3.0
        ports:
        - containerPort: 8081
        imagePullPolicy: Always
        env:
        - name: SCHEMA_REGISTRY_HOST_NAME
          value: schema-registry
        - name: SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL
          value:***
        - name: SCHEMA_REGISTRY_LISTENERS
          value: http://0.0.0.0:8081
        command:
        - bash
        - -c
        - unset SCHEMA_REGISTRY_PORT; /etc/confluent/docker/run

Service:
apiVersion: v1
kind: Service
metadata:
  annotations: 
    service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
  name: schema-registry
  namespace:***
  labels:
    app: schema-registry
spec:
  selector:
    app: schema-registry
  ports:
  - port: 8081
  type: LoadBalancer

希望能有所帮助!

wlzqhblo

wlzqhblo2#

防火墙规则的一个简单问题是问题的原因。服务和部署配置正常。无论如何谢谢你!

相关问题