无法卷曲来自高山豆荚的Redis服务

问题描述 投票:-1回答:1

我有这个Yaml清单供Redis使用

apiVersion: v1
kind: Pod
metadata:
  name: redis-pod
  namespace: redis-namespace
  labels:
    app: redis
spec:
  containers:
  - name: redis-cntr
    image: redis
    imagePullPolicy: IfNotPresent
    ports:
    - name: redis-port
      containerPort: 6379
    envFrom:
    - secretRef:
        name: redis-secret
    command:
    - redis-server
    readinessProbe:
      exec:
        command:
        - redis-cli
        - ping
      initialDelaySeconds: 3
      periodSeconds: 10
      timeoutSeconds: 1
      successThreshold: 1
      failureThreshold: 3
    volumeMounts:
    - name: redis-vol
      mountPath: /data
    - name: config
      mountPath: /usr/local/etc/redis
  volumes:
  - name: redis-vol
    emptyDir: {}
  - name: config
    configMap:
      name: redis-config
      items:
      - key: redis-config
        path: redis.conf

---
apiVersion: v1
kind: Service
metadata:
  name: redis-service
  namespace: redis-namespace
spec:
  type: ClusterIP
  selector:
    app: redis
  ports:
  - name: redis-srv-port
    port: 6379
    targetPort: redis-port
    protocol: TCP

我运行此清单,并且pod正在运行(没有错误),并且服务为:

$ kubectl describe service redis-service
Name:              redis-service
Namespace:         redis-namespace
Labels:            <none>
Annotations:       Selector:  app=redis
Type:              ClusterIP
IP:                10.107.206.191
Port:              redis-srv-port  6379/TCP
TargetPort:        redis-port/TCP
Endpoints:         172.17.0.5:6379
Session Affinity:  None
Events:            <none>

为了测试来自另一个容器的连接,我创建了一个交互式容器:

$ kubectl run -it alpine --image=alpine --restart=Never -- /bin/sh

我尝试用curl redis-service:6379卷曲redis pod,但是返回curl: (1) Received HTTP/0.9 when not allowed。我尝试做curl -u default:mysecretpassword redis-service:6379并获得相同的结果。我做了一个nslookup

$ / # nslookup redis-service
Server:     10.96.0.10
Address:    10.96.0.10:53

Name:   redis-service.redis-namespace.svc.cluster.local
Address: 10.107.206.191

如果我卷曲端点curl 172.17.0.5:6379,我会得到相同的结果。两个吊舱都在同一名称空间上。知道为什么高山吊舱无法卷曲Redis服务吗?不确定是否可以卷曲服务对于其他应用程序能够连接到Redis Pod是否至关重要。

注意:redis.conf具有以下更改:

requirepass mysecretpass

# bind 127.0.0.1 //已评论

appendonly yes

protected-mode yes

kubernetes redis minikube alpine kubernetes-pod
1个回答
0
投票

Redis未将HTTP协议用于客户端连接。因此,任何HTTP客户端(例如CURL)都无法直接与Redis服务器通信。

© www.soinside.com 2019 - 2024. All rights reserved.