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

kubernates create KIND cluster ofter reboot error: The connection to the server 127.0.0.1:32768 was refused - did you specify the right host or port? #1473

Closed
shivamnc opened this issue Apr 13, 2020 · 6 comments
Labels
triage/duplicate Indicates an issue is a duplicate of other open issue.

Comments

@shivamnc
Copy link

kubernates create KIND cluster ofter reboot error:

The connection to the server 127.0.0.1:32768 was refused - did you specify the right host or port?

@BenTheElder
Copy link
Member

/triage duplicate
This is #148
I intend to send more PRs tomorrow.

@k8s-ci-robot k8s-ci-robot added the triage/duplicate Indicates an issue is a duplicate of other open issue. label Apr 13, 2020
@BenTheElder
Copy link
Member

For now you'll have to delete and create it again when you reboot.

@shivamnc
Copy link
Author

/triage duplicate
This is #148

As given shell scripts

[root@mainnode ~]# kubectl get nodes
The connection to the server 127.0.0.1:32768 was refused - did you specify the right host or port?
[root@mainnode ~]#

#!/usr/bin/env bash
KIND_CLUSTER="kind"
KIND_CTX="kind-${KIND_CLUSTER}"

for container in $(kind get nodes --name ${KIND_CLUSTER}); do
[[ $(docker inspect -f '{{.State.Running}}' $container) == "true" ]] || docker start $container
done
sleep 1
docker exec ${KIND_CLUSTER}-control-plane sh -c 'mount -o remount,ro /sys; kill -USR1 1'
kubectl config set clusters.${KIND_CTX}.server $(kind get kubeconfig --name ${KIND_CLUSTER} -q | yq read -j - | jq -r '.clusters[].cluster.server')
kubectl config set clusters.${KIND_CTX}.certificate-authority-data $(kind get kubeconfig --name ${KIND_CLUSTER} -q | yq read -j - | jq -r '.clusters[].cluster."certificate-authority-data"')
kubectl config set users.${KIND_CTX}.client-certificate-data $(kind get kubeconfig --name ${KIND_CLUSTER} -q | yq read -j - | jq -r '.users[].user."client-certificate-data"')
kubectl config set users.${KIND_CTX}.client-key-data $(kind get kubeconfig --name ${KIND_CLUSTER} -q | yq read -j - | jq -r '.users[].user."client-key-data"')

result:

[root@mainnode opt]# ./kindflush.sh
kind-control-plane
./kindflush.sh: line 10: yq: command not found
./kindflush.sh: line 10: jq: command not found
Sets an individual value in a kubeconfig file

PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may
not contain dots.

PROPERTY_VALUE is the new value you wish to set. Binary fields such as 'certificate-authority-data' expect a base64
encoded string unless the --set-raw-bytes flag is used.

Specifying a attribute name that already exists will merge new fields on top of existing values.

Examples:

Set server field on the my-cluster cluster to https://1.2.3.4

kubectl config set clusters.my-cluster.server https://1.2.3.4

Set certificate-authority-data field on the my-cluster cluster.

kubectl config set clusters.my-cluster.certificate-authority-data $(echo "cert_data_here" | base64 -i -)

Set cluster field in the my-context context to my-cluster.

kubectl config set contexts.my-context.cluster my-cluster

Set client-key-data field in the cluster-admin user using --set-raw-bytes option.

kubectl config set users.cluster-admin.client-key-data cert_data_here --set-raw-bytes=true

Options:
--set-raw-bytes=false: When writing a []byte PROPERTY_VALUE, write the given string directly without base64
decoding.

Usage:
kubectl config set PROPERTY_NAME PROPERTY_VALUE [options]

Use "kubectl options" for a list of global command-line options (applies to all commands).
error: Unexpected args: [clusters.kind-kind.server]
./kindflush.sh: line 11: yq: command not found
./kindflush.sh: line 11: jq: command not found
Sets an individual value in a kubeconfig file

PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may
not contain dots.

PROPERTY_VALUE is the new value you wish to set. Binary fields such as 'certificate-authority-data' expect a base64
encoded string unless the --set-raw-bytes flag is used.

Specifying a attribute name that already exists will merge new fields on top of existing values.

Examples:

Set server field on the my-cluster cluster to https://1.2.3.4

kubectl config set clusters.my-cluster.server https://1.2.3.4

Set certificate-authority-data field on the my-cluster cluster.

kubectl config set clusters.my-cluster.certificate-authority-data $(echo "cert_data_here" | base64 -i -)

Set cluster field in the my-context context to my-cluster.

kubectl config set contexts.my-context.cluster my-cluster

Set client-key-data field in the cluster-admin user using --set-raw-bytes option.

kubectl config set users.cluster-admin.client-key-data cert_data_here --set-raw-bytes=true

Options:
--set-raw-bytes=false: When writing a []byte PROPERTY_VALUE, write the given string directly without base64
decoding.

Usage:
kubectl config set PROPERTY_NAME PROPERTY_VALUE [options]

Use "kubectl options" for a list of global command-line options (applies to all commands).
error: Unexpected args: [clusters.kind-kind.certificate-authority-data]
./kindflush.sh: line 12: yq: command not found
./kindflush.sh: line 12: jq: command not found
Sets an individual value in a kubeconfig file

PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may
not contain dots.

PROPERTY_VALUE is the new value you wish to set. Binary fields such as 'certificate-authority-data' expect a base64
encoded string unless the --set-raw-bytes flag is used.

Specifying a attribute name that already exists will merge new fields on top of existing values.

Examples:

Set server field on the my-cluster cluster to https://1.2.3.4

kubectl config set clusters.my-cluster.server https://1.2.3.4

Set certificate-authority-data field on the my-cluster cluster.

kubectl config set clusters.my-cluster.certificate-authority-data $(echo "cert_data_here" | base64 -i -)

Set cluster field in the my-context context to my-cluster.

kubectl config set contexts.my-context.cluster my-cluster

Set client-key-data field in the cluster-admin user using --set-raw-bytes option.

kubectl config set users.cluster-admin.client-key-data cert_data_here --set-raw-bytes=true

Options:
--set-raw-bytes=false: When writing a []byte PROPERTY_VALUE, write the given string directly without base64
decoding.

Usage:
kubectl config set PROPERTY_NAME PROPERTY_VALUE [options]

Use "kubectl options" for a list of global command-line options (applies to all commands).
error: Unexpected args: [users.kind-kind.client-certificate-data]
./kindflush.sh: line 13: yq: command not found
./kindflush.sh: line 13: jq: command not found
Sets an individual value in a kubeconfig file

PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may
not contain dots.

PROPERTY_VALUE is the new value you wish to set. Binary fields such as 'certificate-authority-data' expect a base64
encoded string unless the --set-raw-bytes flag is used.

Specifying a attribute name that already exists will merge new fields on top of existing values.

Examples:

Set server field on the my-cluster cluster to https://1.2.3.4

kubectl config set clusters.my-cluster.server https://1.2.3.4

Set certificate-authority-data field on the my-cluster cluster.

kubectl config set clusters.my-cluster.certificate-authority-data $(echo "cert_data_here" | base64 -i -)

Set cluster field in the my-context context to my-cluster.

kubectl config set contexts.my-context.cluster my-cluster

Set client-key-data field in the cluster-admin user using --set-raw-bytes option.

kubectl config set users.cluster-admin.client-key-data cert_data_here --set-raw-bytes=true

Options:
--set-raw-bytes=false: When writing a []byte PROPERTY_VALUE, write the given string directly without base64
decoding.

Usage:
kubectl config set PROPERTY_NAME PROPERTY_VALUE [options]

Use "kubectl options" for a list of global command-line options (applies to all commands).
error: Unexpected args: [users.kind-kind.client-key-data]
[root@mainnode opt]#

next shell script:

#!/usr/bin/env bash

172.17.0.2 - worker

172.17.0.3 - external-load-balancer

172.17.0.4 - plane

172.17.0.5 - plane2

172.17.0.6 - worker3

172.17.0.7 - plane3

for CONTAINER in control-plane; do
docker start kind-${CONTAINER}
sleep 10
docker exec -ti kind-${CONTAINER} ip a | grep 192.168
echo
done

result :
[root@mainnode opt]# ./doc.sh
kind-control-plane

[root@mainnode opt]#

[root@mainnode opt]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
kind-control-plane Ready master 11h v1.17.0
[root@mainnode opt]#

Finally its work thanks , both scripts should have to apply then only works.

@pramodrj07
Copy link

Does this have to be done manually? Or is it part of the new release?
Asking since i am facing the error even today!

@BenTheElder
Copy link
Member

Single node clusters should reboot fine. Multi node clusters may encounter issues currently (please see open issues in the tracker)

@Vishwajeetdeulkar
Copy link

Hi,

getting the same error as
" The connection to the server 127.0.0.1:33419 was refused - did you specify the right host or port? "
while running command sudo kubectl version
O/P : Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.1", GitCommit:"86ec240af8cbd1b60bcc4c03c20da9b98005b92e", GitTreeState:"clean", BuildDate:"2021-12-16T11:41:01Z", GoVersion:"go1.17.5", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server 127.0.0.1:33419 was refused - did you specify the right host or port?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage/duplicate Indicates an issue is a duplicate of other open issue.
Projects
None yet
Development

No branches or pull requests

5 participants