|
| 1 | +kind: secret |
| 2 | +name: {{ include "redpanda.name" . }}-init |
| 3 | +type: opaque |
| 4 | +data: |
| 5 | + encoding: plain |
| 6 | + payload: | |
| 7 | + #!/bin/bash |
| 8 | + set -euo pipefail |
| 9 | +
|
| 10 | + # Derive pod identity from hostname (e.g. myapp-cluster-2 -> ordinal=2, cluster=myapp-cluster) |
| 11 | + ORDINAL=$(echo "$HOSTNAME" | awk -F'-' '{print $NF}') |
| 12 | + CLUSTER_NAME=$(echo "$HOSTNAME" | sed 's/-[0-9]*$//') |
| 13 | + NODE_FQDN="${HOSTNAME}.${CLUSTER_NAME}" |
| 14 | +
|
| 15 | + # Build seed_servers so every broker knows the full cluster topology on first boot |
| 16 | + SEED_SERVERS="" |
| 17 | + for i in $(seq 0 $(( {{ .Values.redpanda.replicas }} - 1 ))); do |
| 18 | + SEED_SERVERS="${SEED_SERVERS} - host: |
| 19 | + address: ${CLUSTER_NAME}-${i}.${CLUSTER_NAME} |
| 20 | + port: 33145 |
| 21 | + " |
| 22 | + done |
| 23 | +
|
| 24 | + cat > /etc/redpanda/redpanda.yaml << REDPANDA_CFG |
| 25 | + redpanda: |
| 26 | + data_directory: /var/lib/redpanda/data |
| 27 | + node_id: ${ORDINAL} |
| 28 | + enable_sasl: true |
| 29 | + superusers: |
| 30 | + - {{ (index .Values.redpanda.auth.users 0).username }} |
| 31 | + {{- range .Values.redpanda.auth.superusers }} |
| 32 | + - {{ . }} |
| 33 | + {{- end }} |
| 34 | + seed_servers: |
| 35 | + ${SEED_SERVERS} |
| 36 | + rpc_api: |
| 37 | + address: 0.0.0.0 |
| 38 | + port: 33145 |
| 39 | + advertised_rpc_api: |
| 40 | + address: ${NODE_FQDN} |
| 41 | + port: 33145 |
| 42 | + kafka_api: |
| 43 | + - address: 0.0.0.0 |
| 44 | + port: {{ .Values.redpanda.listeners.kafka.internal.port }} |
| 45 | + name: internal |
| 46 | + authentication_method: sasl |
| 47 | + {{- if .Values.redpanda.listeners.kafka.external }} |
| 48 | + - address: 0.0.0.0 |
| 49 | + port: {{ .Values.redpanda.listeners.kafka.external.directReplicaRouting.containerPort }} |
| 50 | + name: external |
| 51 | + authentication_method: sasl |
| 52 | + {{- end }} |
| 53 | + advertised_kafka_api: |
| 54 | + - address: ${NODE_FQDN} |
| 55 | + port: {{ .Values.redpanda.listeners.kafka.internal.port }} |
| 56 | + name: internal |
| 57 | + {{- if .Values.redpanda.listeners.kafka.external }} |
| 58 | + - address: ${ORDINAL}.{{ .Values.redpanda.listeners.kafka.external.directReplicaRouting.publicAddress }} |
| 59 | + port: {{ .Values.redpanda.listeners.kafka.external.directReplicaRouting.containerPort }} |
| 60 | + name: external |
| 61 | + {{- end }} |
| 62 | + admin_api: |
| 63 | + - address: 0.0.0.0 |
| 64 | + port: {{ .Values.redpanda.listeners.adminApi.port }} |
| 65 | + default_topic_replications: {{ include "redpanda.defaultReplicationFactor" . }} |
| 66 | + transaction_coordinator_replication: {{ include "redpanda.defaultReplicationFactor" . }} |
| 67 | + id_allocator_replication: {{ include "redpanda.defaultReplicationFactor" . }} |
| 68 | + kafka_api_allow_everyone_if_no_acl_is_set_on_client_request: {{ .Values.redpanda.acl.allowEveryoneIfNoAclFound }} |
| 69 | + {{- if .Values.redpanda.secrets.cluster_id }} |
| 70 | + cluster_id: {{ .Values.redpanda.secrets.cluster_id | quote }} |
| 71 | + {{- end }} |
| 72 | + {{- range $key, $value := .Values.redpanda.extra_configurations }} |
| 73 | + {{ $key }}: {{ $value }} |
| 74 | + {{- end }} |
| 75 | +
|
| 76 | + schema_registry: |
| 77 | + schema_registry_api: |
| 78 | + - address: 0.0.0.0 |
| 79 | + port: {{ .Values.redpanda.listeners.schemaRegistry.port }} |
| 80 | + authentication_method: http_basic |
| 81 | + {{- if .Values.redpanda.listeners.pandaproxy.enabled }} |
| 82 | +
|
| 83 | + pandaproxy: |
| 84 | + pandaproxy_api: |
| 85 | + - address: 0.0.0.0 |
| 86 | + port: {{ .Values.redpanda.listeners.pandaproxy.port }} |
| 87 | + authentication_method: http_basic |
| 88 | + {{- end }} |
| 89 | + REDPANDA_CFG |
| 90 | +
|
| 91 | + exec redpanda start --config /etc/redpanda/redpanda.yaml |
0 commit comments