Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[stable/redis] Slave fails to connect to master with connection timeout #17245

Closed
carmenlau opened this issue Sep 19, 2019 · 24 comments · Fixed by #20437
Closed

[stable/redis] Slave fails to connect to master with connection timeout #17245

carmenlau opened this issue Sep 19, 2019 · 24 comments · Fixed by #20437
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@carmenlau
Copy link

Describe the bug
Slave fails to connect to master with connection timeout.

Which chart:
stable/redis version 9.1.11

What happened:
Following is the log of slave pod redis container.

1:S 19 Sep 2019 10:12:17.872 # Unable to connect to MASTER: Connection timed out

How to reproduce it (as minimally and precisely as possible):
Install stable/redis with cluster and networkpolicy enabled.

Anything else we need to know:
I tried removing the egress part of the network policy manually, then the slaves can connect to the master successfully.

@juan131
Copy link
Collaborator

juan131 commented Sep 20, 2019

Hi @carmenlau

I was unable to reproduce the issue using the same version of the chart and installing the chart using the parameters below:

$ helm install stable/redis --set networkPolicy.enabled=true --name my-release

As you can see in the logs:

$ kubectl logs my-release-redis-slave-0
11:45:02.13 INFO  ==> ** Starting Redis **
...
1:S 20 Sep 2019 11:45:32.209 * MASTER <-> REPLICA sync started
1:S 20 Sep 2019 11:45:32.209 * Non blocking connect for SYNC fired the event.
1:S 20 Sep 2019 11:45:32.210 * Master replied to PING, replication can continue...
1:S 20 Sep 2019 11:45:32.211 * Partial resynchronization not possible (no cached master)
1:S 20 Sep 2019 11:45:32.212 * Full resync from master: 3c17aa9f3441d76d39243dfd7cae2dd195269e93:0
1:S 20 Sep 2019 11:45:32.250 * MASTER <-> REPLICA sync: receiving 175 bytes from master
1:S 20 Sep 2019 11:45:32.251 * MASTER <-> REPLICA sync: Flushing old data
1:S 20 Sep 2019 11:45:32.251 * MASTER <-> REPLICA sync: Loading DB in memory
1:S 20 Sep 2019 11:45:32.251 * MASTER <-> REPLICA sync: Finished with success

Could you share the complete set of parameters you're using?

@carmenlau
Copy link
Author

Thanks for your reply @juan131! I used the values-production.yaml file from the repo. The only different between my config and values-production.yaml is, I changed sentinel.enabled to true and cluster.slaveCount from 3 to 2. Please find my config below.

## Global Docker image parameters
## Please, note that this will override the image parameters, including dependencies, configured to use the global value
## Current available global Docker image parameters: imageRegistry and imagePullSecrets
##
# global:
#   imageRegistry: myRegistryName
#   imagePullSecrets:
#     - myRegistryKeySecretName
#   storageClass: myStorageClass

## Bitnami Redis image version
## ref: https://hub.docker.com/r/bitnami/redis/tags/
##
image:
  registry: docker.io
  repository: bitnami/redis
  ## Bitnami Redis image tag
  ## ref: https://github.com/bitnami/bitnami-docker-redis#supported-tags-and-respective-dockerfile-links
  ##
  tag: 5.0.5-debian-9-r138
  ## Specify a imagePullPolicy
  ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
  ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
  ##
  pullPolicy: IfNotPresent
  ## Optionally specify an array of imagePullSecrets.
  ## Secrets must be manually created in the namespace.
  ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
  ##
  # pullSecrets:
  #   - myRegistryKeySecretName

## String to partially override redis.fullname template (will maintain the release name)
##
# nameOverride:

## String to fully override redis.fullname template
##
# fullnameOverride:

## Cluster settings
cluster:
  enabled: true
  slaveCount: 2

## Use redis sentinel in the redis pod. This will disable the master and slave services and
## create one redis service with ports to the sentinel and the redis instances
sentinel:
  enabled: true
  ## Bitnami Redis Sentintel image version
  ## ref: https://hub.docker.com/r/bitnami/redis-sentinel/tags/
  ##
  image:
    registry: docker.io
    repository: bitnami/redis-sentinel
    ## Bitnami Redis image tag
    ## ref: https://github.com/bitnami/bitnami-docker-redis-sentinel#supported-tags-and-respective-dockerfile-links
    ##
    tag: 5.0.5-debian-9-r131
    ## Specify a imagePullPolicy
    ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
    ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
    ##
    pullPolicy: IfNotPresent
    ## Optionally specify an array of imagePullSecrets.
    ## Secrets must be manually created in the namespace.
    ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
    ##
    # pullSecrets:
    #   - myRegistryKeySecretName
  masterSet: mymaster
  initialCheckTimeout: 5
  quorum: 2
  downAfterMilliseconds: 60000
  failoverTimeout: 18000
  parallelSyncs: 1
  port: 26379
  ## Additional Redis configuration for the sentinel nodes
  ## ref: https://redis.io/topics/config
  ##
  configmap:
  ## Configure extra options for Redis Sentinel liveness and readiness probes
  ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes)
  ##
  livenessProbe:
    enabled: true
    initialDelaySeconds: 5
    periodSeconds: 5
    timeoutSeconds: 5
    successThreshold: 1
    failureThreshold: 5
  readinessProbe:
    enabled: true
    initialDelaySeconds: 5
    periodSeconds: 5
    timeoutSeconds: 1
    successThreshold: 1
    failureThreshold: 5
  ## Redis Sentinel resource requests and limits
  ## ref: http://kubernetes.io/docs/user-guide/compute-resources/
  # resources:
  #   requests:
  #     memory: 256Mi
  #     cpu: 100m
  ## Redis Sentinel Service properties
  service:
    ##  Redis Sentinel Service type
    type: ClusterIP
    sentinelPort: 26379
    redisPort: 6379

    ## Specify the nodePort value for the LoadBalancer and NodePort service types.
    ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
    ##
    # sentinelNodePort:
    # redisNodePort:

    ## Provide any additional annotations which may be required. This can be used to
    ## set the LoadBalancer service type to internal only.
    ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer
    ##
    annotations: {}
    loadBalancerIP:

## Specifies the Kubernetes Cluster's Domain Name.
##
clusterDomain: cluster.local

networkPolicy:
  ## Specifies whether a NetworkPolicy should be created
  ##
  enabled: true

  ## The Policy model to apply. When set to false, only pods with the correct
  ## client label will have network access to the port Redis is listening
  ## on. When true, Redis will accept connections from any source
  ## (with the correct destination port).
  ##
  # allowExternal: true

serviceAccount:
  ## Specifies whether a ServiceAccount should be created
  ##
  create: false
  ## The name of the ServiceAccount to use.
  ## If not set and create is true, a name is generated using the fullname template
  name:

rbac:
  ## Specifies whether RBAC resources should be created
  ##
  create: false

  role:
    ## Rules to create. It follows the role specification
    # rules:
    #  - apiGroups:
    #    - extensions
    #    resources:
    #      - podsecuritypolicies
    #    verbs:
    #      - use
    #    resourceNames:
    #      - gce.unprivileged
    rules: []

## Redis pod Security Context
securityContext:
  enabled: true
  fsGroup: 1001
  runAsUser: 1001

## Use password authentication
usePassword: true
## Redis password (both master and slave)
## Defaults to a random 10-character alphanumeric string if not set and usePassword is true
## ref: https://github.com/bitnami/bitnami-docker-redis#setting-the-server-password-on-first-run
##
password:
## Use existing secret (ignores previous password)
# existingSecret:

## Mount secrets as files instead of environment variables
usePasswordFile: false

## Persist data to a persistent volume (Redis Master)
persistence: {}
  ## A manually managed Persistent Volume and Claim
  ## Requires persistence.enabled: true
  ## If defined, PVC must be created manually before volume will be bound
  # existingClaim:

# Redis port
redisPort: 6379

##
## Redis Master parameters
##
master:
  ## Redis command arguments
  ##
  ## Can be used to specify command line arguments, for example:
  ##
  command: "/run.sh"
  ## Additional Redis configuration for the master nodes
  ## ref: https://redis.io/topics/config
  ##
  configmap:
  ## Redis additional command line flags
  ##
  ## Can be used to specify command line flags, for example:
  ##
  ## extraFlags:
  ##  - "--maxmemory-policy volatile-ttl"
  ##  - "--repl-backlog-size 1024mb"
  extraFlags: []
  ## Comma-separated list of Redis commands to disable
  ##
  ## Can be used to disable Redis commands for security reasons.
  ## Commands will be completely disabled by renaming each to an empty string.
  ## ref: https://redis.io/topics/security#disabling-of-specific-commands
  ##
  disableCommands:
  - FLUSHDB
  - FLUSHALL

  ## Redis Master additional pod labels and annotations
  ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
  podLabels: {}
  podAnnotations: {}

  ## Redis Master resource requests and limits
  ## ref: http://kubernetes.io/docs/user-guide/compute-resources/
  # resources:
  #   requests:
  #     memory: 256Mi
  #     cpu: 100m
  ## Use an alternate scheduler, e.g. "stork".
  ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/
  ##
  # schedulerName:

  ## Configure extra options for Redis Master liveness and readiness probes
  ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes)
  ##
  livenessProbe:
    enabled: true
    initialDelaySeconds: 5
    periodSeconds: 5
    timeoutSeconds: 5
    successThreshold: 1
    failureThreshold: 5
  readinessProbe:
    enabled: true
    initialDelaySeconds: 5
    periodSeconds: 5
    timeoutSeconds: 1
    successThreshold: 1
    failureThreshold: 5

  ## Redis Master Node selectors and tolerations for pod assignment
  ## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector
  ## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#taints-and-tolerations-beta-feature
  ##
  # nodeSelector: {"beta.kubernetes.io/arch": "amd64"}
  # tolerations: []
  ## Redis Master pod/node affinity/anti-affinity
  ##
  affinity: {}

  ## Redis Master Service properties
  service:
    ##  Redis Master Service type
    type: ClusterIP
    port: 6379

    ## Specify the nodePort value for the LoadBalancer and NodePort service types.
    ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
    ##
    # nodePort:

    ## Provide any additional annotations which may be required. This can be used to
    ## set the LoadBalancer service type to internal only.
    ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer
    ##
    annotations: {}
    loadBalancerIP:

  ## Enable persistence using Persistent Volume Claims
  ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
  ##
  persistence:
    enabled: true
    ## The path the volume will be mounted at, useful when using different
    ## Redis images.
    path: /data
    ## The subdirectory of the volume to mount to, useful in dev environments
    ## and one PV for multiple services.
    subPath: ""
    ## redis data Persistent Volume Storage Class
    ## If defined, storageClassName: <storageClass>
    ## If set to "-", storageClassName: "", which disables dynamic provisioning
    ## If undefined (the default) or set to null, no storageClassName spec is
    ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
    ##   GKE, AWS & OpenStack)
    ##
    # storageClass: "-"
    accessModes:
    - ReadWriteOnce
    size: 8Gi

  ## Update strategy, can be set to RollingUpdate or onDelete by default.
  ## https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/#updating-statefulsets
  statefulset:
    updateStrategy: RollingUpdate
    ## Partition update strategy
    ## https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#partitions
    # rollingUpdatePartition:

  ## Redis Master pod priorityClassName
  # priorityClassName: {}

##
## Redis Slave properties
## Note: service.type is a mandatory parameter
## The rest of the parameters are either optional or, if undefined, will inherit those declared in Redis Master
##
slave:
  ## Slave Service properties
  service:
    ## Redis Slave Service type
    type: ClusterIP
    ## Redis port
    port: 6379
    ## Specify the nodePort value for the LoadBalancer and NodePort service types.
    ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
    ##
    # nodePort:

    ## Provide any additional annotations which may be required. This can be used to
    ## set the LoadBalancer service type to internal only.
    ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer
    ##
    annotations: {}
    loadBalancerIP:

  ## Redis slave port
  port: 6379
  ## Can be used to specify command line arguments, for example:
  ##
  command: "/run.sh"
  ## Additional Redis configuration for the slave nodes
  ## ref: https://redis.io/topics/config
  ##
  configmap:
  ## Redis extra flags
  extraFlags: []
  ## List of Redis commands to disable
  disableCommands:
  - FLUSHDB
  - FLUSHALL

  ## Redis Slave pod/node affinity/anti-affinity
  ##
  affinity: {}

  ## Configure extra options for Redis Slave liveness and readiness probes
  ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes)
  ##
  livenessProbe:
    enabled: true
    initialDelaySeconds: 30
    periodSeconds: 10
    timeoutSeconds: 5
    successThreshold: 1
    failureThreshold: 5
  readinessProbe:
    enabled: true
    initialDelaySeconds: 5
    periodSeconds: 10
    timeoutSeconds: 10
    successThreshold: 1
    failureThreshold: 5

  ## Redis slave Resource
  # resources:
  #   requests:
  #     memory: 256Mi
  #     cpu: 100m

  ## Redis slave selectors and tolerations for pod assignment
  # nodeSelector: {"beta.kubernetes.io/arch": "amd64"}
  # tolerations: []

  ## Use an alternate scheduler, e.g. "stork".
  ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/
  ##
  # schedulerName:

  ## Redis slave pod Annotation and Labels
  podLabels: {}
  podAnnotations: {}

  ## Redis slave pod priorityClassName
  # priorityClassName: {}

  ## Enable persistence using Persistent Volume Claims
  ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
  ##
  persistence:
    enabled: true
    ## The path the volume will be mounted at, useful when using different
    ## Redis images.
    path: /data
    ## The subdirectory of the volume to mount to, useful in dev environments
    ## and one PV for multiple services.
    subPath: ""
    ## redis data Persistent Volume Storage Class
    ## If defined, storageClassName: <storageClass>
    ## If set to "-", storageClassName: "", which disables dynamic provisioning
    ## If undefined (the default) or set to null, no storageClassName spec is
    ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
    ##   GKE, AWS & OpenStack)
    ##
    # storageClass: "-"
    accessModes:
    - ReadWriteOnce
    size: 8Gi

  ## Update strategy, can be set to RollingUpdate or onDelete by default.
  ## https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/#updating-statefulsets
  statefulset:
    updateStrategy: RollingUpdate
    ## Partition update strategy
    ## https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#partitions
    # rollingUpdatePartition:

## Prometheus Exporter / Metrics
##
metrics:
  enabled: true

  image:
    registry: docker.io
    repository: bitnami/redis-exporter
    tag: 1.1.1-debian-9-r10
    pullPolicy: IfNotPresent
    ## Optionally specify an array of imagePullSecrets.
    ## Secrets must be manually created in the namespace.
    ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
    ##
    # pullSecrets:
    #   - myRegistryKeySecretName

  ## Metrics exporter resource requests and limits
  ## ref: http://kubernetes.io/docs/user-guide/compute-resources/
  ##
  # resources: {}

  ## Extra arguments for Metrics exporter, for example:
  ## extraArgs:
  ##   check-keys: myKey,myOtherKey
  # extraArgs: {}

  ## Metrics exporter pod priorityClassName
  # priorityClassName: {}
  service:
    type: ClusterIP
    ## Use serviceLoadBalancerIP to request a specific static IP,
    ## otherwise leave blank
    # loadBalancerIP:
    annotations: {}
  ## Metrics exporter pod Annotation and Labels
  podAnnotations:
    prometheus.io/scrape: "true"
    prometheus.io/port: "9121"
  # podLabels: {}

  # Enable this if you're using https://github.com/coreos/prometheus-operator
  serviceMonitor:
    enabled: false
    ## Specify a namespace if needed
    # namespace: monitoring
    # fallback to the prometheus default unless specified
    # interval: 10s
    ## Defaults to what's used if you follow CoreOS [Prometheus Install Instructions](https://github.com/helm/charts/tree/master/stable/prometheus-operator#tldr)
    ## [Prometheus Selector Label](https://github.com/helm/charts/tree/master/stable/prometheus-operator#prometheus-operator-1)
    ## [Kube Prometheus Selector Label](https://github.com/helm/charts/tree/master/stable/prometheus-operator#exporters)
    selector:
      prometheus: kube-prometheus

##
## Init containers parameters:
## volumePermissions: Change the owner of the persist volume mountpoint to RunAsUser:fsGroup
##
volumePermissions:
  enabled: false
  image:
    registry: docker.io
    repository: bitnami/minideb
    tag: stretch
    pullPolicy: Always
    ## Optionally specify an array of imagePullSecrets.
    ## Secrets must be manually created in the namespace.
    ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
    ##
    # pullSecrets:
    #   - myRegistryKeySecretName
  resources: {}
  # resources:
  #   requests:
  #     memory: 128Mi
  #     cpu: 100m

## Redis config file
## ref: https://redis.io/topics/config
##
configmap: |-
  # Enable AOF https://redis.io/topics/persistence#append-only-file
  appendonly yes
  # Disable RDB persistence, AOF persistence already enabled.
  save ""

## Sysctl InitContainer
## used to perform sysctl operation to modify Kernel settings (needed sometimes to avoid warnings)
sysctlImage:
  enabled: false
  command: []
  registry: docker.io
  repository: bitnami/minideb
  tag: stretch
  pullPolicy: Always
  ## Optionally specify an array of imagePullSecrets.
  ## Secrets must be manually created in the namespace.
  ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
  ##
  # pullSecrets:
  #   - myRegistryKeySecretName
  mountHostSys: false
  resources: {}
  # resources:
  #   requests:
  #     memory: 128Mi
  #     cpu: 100m

@juan131
Copy link
Collaborator

juan131 commented Oct 1, 2019

Hi @carmenlau

I was unable to reproduce the issue with your values either. See:

$ helm install stable/redis -f your-values.yaml --name my-release
$ kubectl get networkpolicy my-release-redis -o json | jq '.spec.ingress'
[
  {
    "from": [
      {
        "podSelector": {
          "matchLabels": {
            "my-release-redis-client": "true"
          }
        }
      },
      {
        "podSelector": {
          "matchLabels": {
            "app": "redis",
            "release": "my-release",
            "role": "metrics"
          }
        }
      },
      {
        "podSelector": {
          "matchLabels": {
            "app": "redis",
            "release": "my-release",
            "role": "slave"
          }
        }
      }
    ],
    "ports": [
      {
        "port": 6379,
        "protocol": "TCP"
      },
      {
        "port": 26379,
        "protocol": "TCP"
      }
    ]
  },
  {
    "ports": [
      {
        "port": 9121,
        "protocol": "TCP"
      }
    ]
  }
]
$ kubectl get pods -l app=redis,release=my-release,role=slave
NAME                       READY   STATUS    RESTARTS   AGE
my-release-redis-slave-0   3/3     Running   3          7m11s
my-release-redis-slave-1   3/3     Running   0          6m8s

After some restarts (while the master pod was being initialised) the slave pods were able to connect with it. As you can see, if I inspect the networkpolicy and look for the pods which labels are authorized to connect with the master pod, I obtain the list of slave pods.

@stale
Copy link

stale bot commented Oct 31, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

@stale stale bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 31, 2019
@artooro
Copy link

artooro commented Nov 6, 2019

I'm having the same issue with a new deployment. My values.yaml file is pretty simple.

cluster:
  enabled: true
  slaveCount: 1
networkPolicy:
  enabled: true
rbac:
  create: true
usePassword: false

@stale stale bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 6, 2019
@anirudhreddy6
Copy link

Having the same issue.
Deployed by using the same production values.
Slave is not able to connect to the master.

@juan131
Copy link
Collaborator

juan131 commented Nov 7, 2019

Hi @artooro @anirudhreddy6

What version of the Redis Helm chart are you using?

@artooro
Copy link

artooro commented Nov 7, 2019

@juan131 here is what I've deployed

helm3 -n redis list
redis	redis    	3       	2019-11-06 12:13:47.789516 -0500 EST	deployed	redis-9.5.1	5.0.5

@anirudhreddy6
Copy link

Hi Juan131....i redeployed the same chart in a newly provisioned cluster (1.12 k8s).
Slaves are able to connect now.
I have another question ...how do we expose the redis cluster externally?

@a7i
Copy link
Contributor

a7i commented Nov 8, 2019

@anirudhreddy6

In your YAML configuration, change the service to type LoadBalancer. This could be for master.service.type and/or sentinel.service.type

    service:
      type: LoadBalancer

@ledroide
Copy link

I'm investigating the same issue : when activated, the NetworkPolicy gives this issue. If I disable the network policy, then slaves can connect to master.

@rsecob
Copy link
Contributor

rsecob commented Nov 12, 2019

Having the same issue over here with cluster.enabled=true and networkPolicy.enabled=true on GKE v1.14.7-gke.14. Somehow it seems to affect only slaves and even master if I kubectl exec into it and try to connect with the redis-cli with redis-service-name.namespace.svc, pods having the label *-redis-client=true seems to work fine. I believe our cluster has a policy that prevents other pods from other namespaces to communicate with each other. By playing around with the egress policy I sometimes was able to allow connections but can't tell for sure if what I'm doing is disruptive to the intended effect.

@ledroide
Copy link

@rsecob : can you please share here your egress policy that you think it could allow connections from redis slave to master ?

@rsecob
Copy link
Contributor

rsecob commented Nov 14, 2019

I basically added namespaceSelector: {} in the to property allowing all pods from all namespaces matching the PodSelector. It works but I'm afraid that is not what is desired with this network policy, am I right? Also I added a dash before the to property, without it, it doesn't work, dont ask me why.

@TheDetweiler
Copy link

TheDetweiler commented Nov 15, 2019

I am having the same issues as everyone above. When the networkPolicy is set too enabled: true the logs from the slave yield the following: 1:S 15 Nov 2019 20:38:45.780 # Unable to connect to MASTER: Connection timed out . However, unlike the suggestions before, if i try and label the slave pod with the label provided from the redis install (Note: Since NetworkPolicy is enabled, only pods with label redis-1573849901-client=true" will be able to connect to redis.) the pods still fail to connect to the master. And, i saw a few suggestions that turning on the networkPolicy.allowExternal: true while the NetworkPolicy was also enabled would help but that also failed. The only solution i found to resolve this problem was to disable the network policy. For reference too was using the values-production.yaml from the stable repo ( i dont want to plug up my post with a huge yaml but you can find the source here) with my only modification setting the networkPolicy to false like so

networkPolicy:
  ## Specifies whether a NetworkPolicy should be created
  ##
  enabled: false

does anyone have any idea on a reliable way to fix this?

@ledroide
Copy link

I basically added namespaceSelector: {} in the to property allowing all pods from all namespaces matching the PodSelector.

@rsecob : I also tried defining the namespaceSelector to match my namespace label, but it didn't change anything. Here is my networkPolicy spec section :

spec:
  podSelector:
    matchLabels:
      app: redis
      release: webs-sentinel
  policyTypes:
  - Ingress
  - Egress
  ingress:
  - ports:
    - port: 6379
      protocol: TCP
    - port: 26379
      protocol: TCP
  - ports:
    - port: 9121
      protocol: TCP
  egress:
  - ports:
    - port: 6379
      protocol: TCP
    - port: 26379
      protocol: TCP
    to:
    - podSelector:
        matchLabels:
          app: redis
          release: webs-sentinel
    - namespaceSelector:
        matchLabels:
          product: pervers-pepere

@rsecob
Copy link
Contributor

rsecob commented Nov 19, 2019

Try again putting a dash before the to and let me know if it changes anything:

- to:
    - podSelector:
        matchLabels:
          app: redis
          release: webs-sentinel
    - namespaceSelector:
        matchLabels:
          product: pervers-pepere

for some reasons it seemed to have an effect on my end

@ledroide
Copy link

Try again putting a dash before the to and let me know if it changes anything

@rsecob : Same error when applying the network policy with a dash before the 'to', as you asked :

1:S 21 Nov 2019 08:21:20.323 * Connecting to MASTER webs-sentinel-redis-master-0.webs-sentinel-redis-headless.webs.svc.poc.kube:6379
1:S 21 Nov 2019 08:21:40.347 # Unable to connect to MASTER: Connection timed out

When I delete the network policy, and restart the slave statefulset, pods are Running and I get very different logs instead :

1:S 21 Nov 2019 08:26:21.402 * Connecting to MASTER webs-sentinel-redis-master-0.webs-sentinel-redis-headless.webs.svc.poc.kube:6379
1:S 21 Nov 2019 08:26:21.404 * MASTER <-> REPLICA sync started
1:S 21 Nov 2019 08:26:21.404 * Non blocking connect for SYNC fired the event.
1:S 21 Nov 2019 08:26:21.404 * Master replied to PING, replication can continue...
1:S 21 Nov 2019 08:26:21.405 * Partial resynchronization not possible (no cached master)
1:S 21 Nov 2019 08:26:21.406 * Full resync from master: 2152ae0e50d8d279990dd310413b456eb73cb652:0
1:S 21 Nov 2019 08:26:21.419 * MASTER <-> REPLICA sync: receiving 175 bytes from master
1:S 21 Nov 2019 08:26:21.420 * MASTER <-> REPLICA sync: Flushing old data
1:S 21 Nov 2019 08:26:21.420 * MASTER <-> REPLICA sync: Loading DB in memory
1:S 21 Nov 2019 08:26:21.422 * MASTER <-> REPLICA sync: Finished with success

@stale
Copy link

stale bot commented Dec 21, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

@stale stale bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 21, 2019
@stale
Copy link

stale bot commented Jan 4, 2020

This issue is being automatically closed due to inactivity.

@engineerakki
Copy link

Facing same issue.
Anyone found a resolution ?

@juan131
Copy link
Collaborator

juan131 commented Apr 10, 2020

Hi,

Given the stable deprecation timeline, this Bitnami maintained Helm chart is now located at bitnami/charts. Please visit the bitnami/charts GitHub repository to create Issues or PRs.

In this issue, we tried to explain more carefully the reasons and motivations behind this transition, please don't hesitate to add a comment in this issue if you have any question related to the migration itself.

Regards,

@itninja-hue
Copy link

itninja-hue commented Apr 29, 2020

@engineerakki
my setup: i didn't use bitnami's redis helm chart instead i wrote my own manifests since i m deploying redis as a side car to my micro-service, and using redis as Master-Replica replication .
Things you should be looking at if you encounter this problem:

  • Is Slave node allowed to resolve DNS, (in my setup redis master don't need to resolve DNS) Network Policies .
  • Is Slave node bound to "0.0.0.0"

Further debugging: use tshark

@juan131
Copy link
Collaborator

juan131 commented Jul 20, 2020

Given the stable deprecation timeline, this Bitnami maintained Helm chart is now located at bitnami/charts. Please visit the bitnami/charts GitHub repository to create Issues or PRs.

In this issue we tried to explain more carefully the reasons and motivations behind this transition, please don't hesitate to add a comment in this issue if you have any question related to the migration itself.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
10 participants