1

I'm installing bitnami/redis with helm-charts, and the install fails with this error:

serializer for text/html; charset=utf-8 doesn't exist

I have isolated the problem, and it seems to come from this configmap.

Which once templated, looks like this:

apiVersion: v1
kind: ConfigMap
metadata:
  name: redis-scripts
  namespace: "XXXXXX"
  labels:
    app.kubernetes.io/name: redis
    helm.sh/chart: redis-16.4.0
    app.kubernetes.io/instance: redis
    app.kubernetes.io/managed-by: Helm
data:
  start-master.sh: |
    #!/bin/bash

    [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
    if [[ ! -f /opt/bitnami/redis/etc/master.conf ]];then
        cp /opt/bitnami/redis/mounted-etc/master.conf /opt/bitnami/redis/etc/master.conf
    fi
    if [[ ! -f /opt/bitnami/redis/etc/redis.conf ]];then
        cp /opt/bitnami/redis/mounted-etc/redis.conf /opt/bitnami/redis/etc/redis.conf
    fi
    ARGS=("--port" "${REDIS_PORT}")
    ARGS+=("--requirepass" "${REDIS_PASSWORD}")
    ARGS+=("--masterauth" "${REDIS_PASSWORD}")
    ARGS+=("--include" "/opt/bitnami/redis/etc/redis.conf")
    ARGS+=("--include" "/opt/bitnami/redis/etc/master.conf")
    exec redis-server "${ARGS[@]}"
  start-replica.sh: |
    #!/bin/bash

    get_port() {
        hostname="$1"
        type="$2"

        port_var=$(echo "${hostname^^}_SERVICE_PORT_$type" | sed "s/-/_/g")
        port=${!port_var}

        if [ -z "$port" ]; then
            case $type in
                "SENTINEL")
                    echo 26379
                    ;;
                "REDIS")
                    echo 6379
                    ;;
            esac
        else
            echo $port
        fi
    }

    get_full_hostname() {
        hostname="$1"
        echo "${hostname}.${HEADLESS_SERVICE}"
    }

    REDISPORT=$(get_port "$HOSTNAME" "REDIS")

    [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
    [[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
    if [[ ! -f /opt/bitnami/redis/etc/replica.conf ]];then
        cp /opt/bitnami/redis/mounted-etc/replica.conf /opt/bitnami/redis/etc/replica.conf
    fi
    if [[ ! -f /opt/bitnami/redis/etc/redis.conf ]];then
        cp /opt/bitnami/redis/mounted-etc/redis.conf /opt/bitnami/redis/etc/redis.conf
    fi

    echo "" >> /opt/bitnami/redis/etc/replica.conf
    echo "replica-announce-port $REDISPORT" >> /opt/bitnami/redis/etc/replica.conf
    echo "replica-announce-ip $(get_full_hostname "$HOSTNAME")" >> /opt/bitnami/redis/etc/replica.conf
    ARGS=("--port" "${REDIS_PORT}")
    ARGS+=("--slaveof" "${REDIS_MASTER_HOST}" "${REDIS_MASTER_PORT_NUMBER}")
    ARGS+=("--requirepass" "${REDIS_PASSWORD}")
    ARGS+=("--masterauth" "${REDIS_MASTER_PASSWORD}")
    ARGS+=("--include" "/opt/bitnami/redis/etc/redis.conf")
    ARGS+=("--include" "/opt/bitnami/redis/etc/replica.conf")
    exec redis-server "${ARGS[@]}"
---

I tried to simplify it more, and found that the problem is in both the functions get_port() and get_full_hostname(). For example, this by itself gives the same error:

apiVersion: v1
kind: ConfigMap
metadata:
  name: redis-scripts
  namespace: "XXXXXX"
  labels:
    app.kubernetes.io/name: redis
    helm.sh/chart: redis-16.4.0
    app.kubernetes.io/instance: redis
    app.kubernetes.io/managed-by: Helm
data:
  start-replica.sh: |
    #!/bin/bash

    get_full_hostname() {
        hostname="$1"
        echo "${hostname}.${HEADLESS_SERVICE}"
    }

---

Do you see anything odd with those lines? They look fine to me and I have no idea where the error is coming from.

I'm using rancher, here's the output of my kubectl version

Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.0", GitCommit:"c2b5237ccd9c0f1d600d3072634ca66cefdf272f", GitTreeState:"clean", BuildDate:"2021-08-04T18:03:20Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.11+vmware.1", GitCommit:"581335ed759cada5037cc08960ce95d73170087f", GitTreeState:"clean", BuildDate:"2021-09-17T00:48:38Z", GoVersion:"go1.15.15", Compiler:"gc", Platform:"linux/amd64"}
WARNING: version difference between client (1.22) and server (1.20) exceeds the supported minor version skew of +/-1

Edit: I tried with kubectl v1.20.11 (the same as the server), same error. Edit2: Found a dirtyfix, just setting architecture: standalone instead of replications doesn't call those buggy scripts.

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37

1 Answers1

0

There are no issues with the bitnami/redis helm chart. I checked it on Kubernetes v1.23.1 and the Redis deployment is running fine.

So, those included ConfigMaps/scripts are fine too.

Run helm version to check your Helm version. Helm by default uses the kubeconfig file located in ~/.kube/config. You can use another file if you set the environment variable $KUBECONFIG.

  1. Check if your ~/.kube/config exists. If not, run the following command:
sudo cp -i /etc/kubernetes/admin.config ~/.kube/config
  1. Check if your ~/.kube/config is properly set up and looks something like this and points to the right kube-apiserver:
apiVersion: v1
clusters:
- cluster:
    certificate-authority: <REDACTED>
    server: https://10.10.1.1:6443 <== This needs to point to the right kube-apiserver address
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    namespace: default
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: <REDACTED>
    client-key-data: <REDACTED>

mozello
  • 1,083
  • 3
  • 8
  • Thanks, but my kubectl is correctly configured, and actually the chart gets deployed if that buggy `configmap` isn't called. – Throwawayz123 Feb 24 '22 at 07:53
  • It's the `hostname` command in the function. Just this by itself ${hostname} gives the error. I have no idea why since that command will be only ran once the script is called? – Throwawayz123 Feb 25 '22 at 09:57
  • Still can't reproduce the issue. @Throwawayz123 Please, add details on how you deploy that redis helm chart. How did you set up the k8s cluster? Do you have the same issue running `helm install my-release bitnami/redis` command without any customization? – mozello Mar 01 '22 at 13:42