首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >吊舱间通信

吊舱间通信
EN

Stack Overflow用户
提问于 2020-07-16 14:19:39
回答 3查看 533关注 0票数 1

我目前正在设置sentry.io,但在openshift 3.11中设置它时遇到了问题

我为sentry本身、postgresqlredismemcache运行了pods,但是根据日志消息,它们无法在一起进行通信。

代码语言:javascript
复制
sentry.exceptions.InvalidConfiguration: Error 111 connecting to 127.0.0.1:6379. Connection refused.

我是否需要创建一个类似于docker的网络,或者在默认情况下,豆荚(都在同一个名称空间中)应该能够相互通信?我获得了整个项目的管理权限,所以我也可以使用控制台,而不仅仅是网络界面。

谨致问候

编辑:为sentry及其服务添加部署配置,并为简单起见添加postgres配置和服务。我还删除了一些不必要的信息与关键字BLANK,如果我走了,请让我知道,我来查。

sentry的部署配置

代码语言:javascript
复制
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
  annotations:
    openshift.io/generated-by: OpenShiftWebConsole
  creationTimestamp: BLANK
  generation: 20
  labels:
    app: sentry
  name: sentry
  namespace: test
  resourceVersion: '506667843'
  selfLink: BLANK
  uid: BLANK
spec:
  replicas: 1
  selector:
    app: sentry
    deploymentconfig: sentry
  strategy:
    activeDeadlineSeconds: 21600
    resources: {}
    rollingParams:
      intervalSeconds: 1
      maxSurge: 25%
      maxUnavailable: 25%
      timeoutSeconds: 600
      updatePeriodSeconds: 1
    type: Rolling
  template:
    metadata:
      annotations:
        openshift.io/generated-by: OpenShiftWebConsole
      creationTimestamp: null
      labels:
        app: sentry
        deploymentconfig: sentry
    spec:
      containers:
        - env:
            - name: SENTRY_SECRET_KEY
              value: Iamsosecret
            - name: C_FORCE_ROOT
              value: '1'
            - name: SENTRY_FILESTORE_DIR
              value: /var/lib/sentry/files/data
          image: BLANK
          imagePullPolicy: Always
          name: sentry
          ports:
            - containerPort: 9000
              protocol: TCP
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /var/lib/sentry/files
              name: sentry-1
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
        - emptyDir: {}
          name: sentry-1
  test: false
  triggers:
    - type: ConfigChange
    - imageChangeParams:
        automatic: true
        containerNames:
          - sentry
        from:
          kind: ImageStreamTag
          name: 'sentry:latest'
          namespace: catcloud
        lastTriggeredImage: BLANK
      type: ImageChange
status:
  availableReplicas: 1
  conditions:
    - lastTransitionTime: BLANK
      lastUpdateTime: BLANK
      message: Deployment config has minimum availability.
      status: 'True'
      type: Available
    - lastTransitionTime: BLANK
      lastUpdateTime: BLANK
      message: replication controller "sentry-19" successfully rolled out
      reason: NewReplicationControllerAvailable
      status: 'True'
      type: Progressing
  details:
    causes:
      - type: ConfigChange
    message: config change
  latestVersion: 19
  observedGeneration: 20
  readyReplicas: 1
  replicas: 1
  unavailableReplicas: 0
  updatedReplicas: 1

sentry服务

代码语言:javascript
复制
apiVersion: v1
kind: Service
metadata:
  annotations:
    openshift.io/generated-by: OpenShiftWebConsole
  creationTimestamp: BLANK
  labels:
    app: sentry
  name: sentry
  namespace: test
  resourceVersion: '505555608'
  selfLink: BLANK
  uid: BLANK
spec:
  clusterIP: BLANK
  ports:
    - name: 9000-tcp
      port: 9000
      protocol: TCP
      targetPort: 9000
  selector:
    deploymentconfig: sentry
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}

postgresql的部署配置

代码语言:javascript
复制
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
  annotations:
    openshift.io/generated-by: OpenShiftWebConsole
  creationTimestamp: BLANK
  generation: 10
  labels:
    app: postgres
    type: backend
  name: postgres
  namespace: test
  resourceVersion: '506664185'
  selfLink: BLANK
  uid: BLANK
spec:
  replicas: 1
  selector:
    app: postgres
    deploymentconfig: postgres
    type: backend
  strategy:
    activeDeadlineSeconds: 21600
    resources: {}
    rollingParams:
      intervalSeconds: 1
      maxSurge: 25%
      maxUnavailable: 25%
      timeoutSeconds: 600
      updatePeriodSeconds: 1
    type: Rolling
  template:
    metadata:
      annotations:
        openshift.io/generated-by: OpenShiftWebConsole
      creationTimestamp: null
      labels:
        app: postgres
        deploymentconfig: postgres
        type: backend
    spec:
      containers:
        - env:
            - name: PGDATA
              value: /var/lib/postgresql/data/sql
            - name: POSTGRES_HOST_AUTH_METHOD
              value: trust
            - name: POSTGRESQL_USER
              value: sentry
            - name: POSTGRESQL_PASSWORD
              value: sentry
            - name: POSTGRESQL_DATABASE
              value: sentry
          image: BLANK
          imagePullPolicy: Always
          name: postgres
          ports:
            - containerPort: 5432
              protocol: TCP
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: volume-uirge
              subPath: sql
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext:
        runAsUser: 2000020900
      terminationGracePeriodSeconds: 30
      volumes:
        - name: volume-uirge
          persistentVolumeClaim:
            claimName: postgressql
  test: false
  triggers:
    - type: ConfigChange
    - imageChangeParams:
        automatic: true
        containerNames:
          - postgres
        from:
          kind: ImageStreamTag
          name: 'postgres:latest'
          namespace: catcloud
        lastTriggeredImage: BLANK
      type: ImageChange
status:
  availableReplicas: 1
  conditions:
    - lastTransitionTime: BLANK
      lastUpdateTime: BLANK
      message: Deployment config has minimum availability.
      status: 'True'
      type: Available
    - lastTransitionTime: BLANK
      lastUpdateTime: BLANK
      message: replication controller "postgres-9" successfully rolled out
      reason: NewReplicationControllerAvailable
      status: 'True'
      type: Progressing
  details:
    causes:
      - type: ConfigChange
    message: config change
  latestVersion: 9
  observedGeneration: 10
  readyReplicas: 1
  replicas: 1
  unavailableReplicas: 0
  updatedReplicas: 1

服务配置postgresql

代码语言:javascript
复制
apiVersion: v1
kind: Service
metadata:
  annotations:
    openshift.io/generated-by: OpenShiftWebConsole
  creationTimestamp: BLANK
  labels:
    app: postgres
    type: backend
  name: postgres
  namespace: catcloud
  resourceVersion: '506548841'
  selfLink: /api/v1/namespaces/catcloud/services/postgres
  uid: BLANK
spec:
  clusterIP: BLANK
  ports:
    - name: 5432-tcp
      port: 5432
      protocol: TCP
      targetPort: 5432
  selector:
    deploymentconfig: postgres
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2020-07-16 14:33:23

在默认情况下,豆荚(即使在同一个名称空间中)也不能直接与对话。您需要创建一个Service,以便允许一个吊舱接收来自另一个吊舱的连接。一般来说,一个吊舱通过后者的服务连接到另一个吊舱,如下所示:

连接信息看起来类似于<servicename>:<serviceport> (例如,elasticsearch-master:9200),而不是localhost:port

有关服务的更多信息,您可以阅读https://kubernetes.io/docs/concepts/services-networking/service/

注:localhost:port只对运行在同一个吊舱内的容器起作用,以便相互连接,就像上面的插图中nginx如何连接到引力对象mgmt和引力对象mgmt一样。

票数 3
EN

Stack Overflow用户

发布于 2020-07-17 07:31:16

对我来说,看起来你没有正确地配置哨兵,这意味着你没有提供哨兵吊舱连接到PostgreSQL吊舱和红荚的凭证。

代码语言:javascript
复制
env:
    - name: SENTRY_SECRET_KEY
      valueFrom:
        secretKeyRef:
          name: sentry-sentry
          key: sentry-secret
    - name: SENTRY_DB_USER
      value: "sentry"
    - name: SENTRY_DB_NAME
      value: "sentry"
    - name: SENTRY_DB_PASSWORD
      valueFrom:
        secretKeyRef:
          name: sentry-postgresql
          key: postgres-password
    - name: SENTRY_POSTGRES_HOST
      value: sentry-postgresql
    - name: SENTRY_POSTGRES_PORT
      value: "5432"
    - name: SENTRY_REDIS_PASSWORD
      valueFrom:
        secretKeyRef:
          name: sentry-redis
          key: redis-password
    - name: SENTRY_REDIS_HOST
      value: sentry-redis
    - name: SENTRY_REDIS_PORT
      value: "6379"
    - name: SENTRY_EMAIL_HOST
      value: "smtp"
    - name: SENTRY_EMAIL_PORT
      value: "25"
    - name: SENTRY_EMAIL_USER
      value: ""
    - name: SENTRY_EMAIL_PASSWORD
      valueFrom:
        secretKeyRef:
          name: sentry-sentry
          key: smtp-password
    - name: SENTRY_EMAIL_USE_TLS
      value: "false"
    - name: SENTRY_SERVER_EMAIL
      value: "sentry@sentry.local"

要获得更多信息,您可以参考他们配置哨兵的位置。

https://github.com/maty21/sentry-kubernetes/blob/master/sentry.yaml

票数 1
EN

Stack Overflow用户

发布于 2020-07-16 14:42:31

对于豆荚之间的通信,localhost127.0.0.1不起作用。

获取任何吊舱的IP

代码语言:javascript
复制
kubectl describe podname

使用另一个吊舱中的IP与上面的吊舱进行通信。

由于pods发生了变化,如果重新创建了Pod,那么理想情况下,应该使用库伯奈特服务,特别是clusterIP类型,用于集群内pod之间的通信。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62936823

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档