Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Piraeus doesn't support IPv6 #48

Open
Frankkkkk opened this issue Aug 27, 2020 · 0 comments
Open

Piraeus doesn't support IPv6 #48

Frankkkkk opened this issue Aug 27, 2020 · 0 comments

Comments

@Frankkkkk
Copy link

Hi,
Piraeus doesn't seem to support IPv6-only clusters.

I've found at least 2 IPv4-only things to fix, but there are likely many more:

diff --git a/dockerfiles/piraeus-init/bin/init-etcd.sh b/dockerfiles/piraeus-init/bin/init-etcd.sh
index 271fa6c..11d026d 100755
--- a/dockerfiles/piraeus-init/bin/init-etcd.sh
+++ b/dockerfiles/piraeus-init/bin/init-etcd.sh
@@ -5,12 +5,19 @@ pod_sts="${POD_NAME/-[0-9]*/}"
 
 cluster=$( seq 0 $(( CLUSTER_SIZE - 1 )) | xargs -tI % echo "${pod_sts}-%=http://${pod_sts}-%.${pod_sts}:${PEER_PORT}" | paste -sd "," - )
 
+if [[ $POD_IP =~ .*:.* ]]; then
+       POD_IP="[$POD_IP]"
+       LOCALHOST='[::1]'
+else
+       LOCALHOST='127.0.0.1'
+fi
+
 # write config file
 cat > /init/etc/etcd/etcd.conf << EOF
 name:                        ${POD_NAME}
 max-txn-ops:                 1024
 listen-peer-urls:            http://${POD_IP}:${PEER_PORT}
-listen-client-urls:          http://${POD_IP}:${CLIENT_PORT},http://127.0.0.1:${CLIENT_PORT}
+listen-client-urls:          http://${POD_IP}:${CLIENT_PORT},http://${LOCALHOST}:${CLIENT_PORT}
 advertise-client-urls:       http://${POD_IP}:${CLIENT_PORT}
 initial-advertise-peer-urls: http://${POD_IP}:${PEER_PORT}
 initial-cluster-token:       ${pod_sts}
diff --git a/dockerfiles/piraeus-init/bin/lib.tools.sh b/dockerfiles/piraeus-init/bin/lib.tools.sh
index 6afea1f..4d30ace 100644
--- a/dockerfiles/piraeus-init/bin/lib.tools.sh
+++ b/dockerfiles/piraeus-init/bin/lib.tools.sh
@@ -1,9 +1,19 @@
 #!/bin/bash
 
 _get_ip_by_if() {
-    ip -f inet address | grep -w "$1" | awk '/inet / {print $2}' | sed 's#/.*##'
+    if [[ $1 =~ .*:.* ]]; then
+        inet=inet6
+    else
+        inet=inet
+    fi
+    ip -f $inet address | grep -w "$1" | awk "/$inet / {print \$2}" | sed 's#/.*##'
 }
 
 _get_if_by_ip() {
-    ip -f inet address | grep -B1 "inet $1" | head -1 | awk '{print $2}' | sed 's/://g'
-}
\ No newline at end of file
+    if [[ $1 =~ .*:.* ]]; then
+        inet=inet6
+    else
+        inet=inet
+    fi
+    ip -f $inet address | grep -B1 "$inet $1" | head -1 | awk '{print $2}' | sed 's/://g'
+}

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant