kubewharf / katalyst-core

Katalyst aims to provide a universal solution to help improve resource utilization and optimize the overall costs in the cloud. This is the core components in Katalyst system, including multiple agents and centralized components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"$KUBEADM_TOKEN" was not of the form "\\A([a-z0-9]{6})\\.([a-z0-9]{16})\\z"

yanxiaoqi932 opened this issue · comments

What happened?

When I set up enhanced kubernetes master:

mkdir -p /etc/kubernetes
export KUBEADM_TOKEN=`kubeadm token generate`
export APISERVER_ADDR=192.168.211.131

kubeadm init --config=/etc/kubernetes/kubeadm-client.yaml --upload-certs -v=5

it shows an error:

initconfiguration.go:306] error unmarshaling configuration schema.GroupVersionKind{Group:"kubeadm.k8s.io", Version:"v1beta3", Kind:"InitConfiguration"}: the bootstrap token "$KUBEADM_TOKEN" was not of the form "\\A([a-z0-9]{6})\\.([a-z0-9]{16})\\z"

What did you expect to happen?

run kubeadm init

How can we reproduce it (as minimally and precisely as possible)?

install enhanced k8s according to https://github.com/kubewharf/katalyst-core/blob/main/docs/install-enhanced-k8s.md

Software version

$ <software> version
# paste output here

I have got the reason. We can't use environment parameters in yaml files in this way, yaml files will think it is a string:

apiVersion: kubeadm.k8s.io/v1beta3
bootstrapTokens:
- groups:
  - system:bootstrappers:kubeadm:default-node-token
  token: $KUBEADM_TOKEN

Maybe katalyst need to fix this bug in https://github.com/kubewharf/katalyst-core/blob/main/docs/install-enhanced-k8s.md

How did you create your kubeadm-client.yaml? If you follow the documentation, it is created using heredoc:

export KUBEADM_TOKEN=`kubeadm token generate`
export APISERVER_ADDR=<your master ip address>

cat <<EOF | tee /etc/kubernetes/kubeadm-client.yaml
...
...
EOF

variable expansion should be the default behavior of heredoc

I didn't have this problem on my side, maybe there was a problem with token generate, can you use echo $KUBEADM_TOKEN to see the KUBEADM_TOKEN value?

I use vim to create kubeadm-client.yaml, this is the problem. We must use tee instead of vim because of the variable expansion of heredoc, if use vim, $KUBEADM_TOKEN will be think as a string "$KUBEADM_TOKEN" in yaml files.

Thanks, this problem has been solved. 😄