Lab Exercises 4.1
kinda stuck here .. maybe somebody know whats wrong
if i try the example from the course :
`
kubectl -n kube-system exec -it etcd-k8s-test.panday.local -- sh -c "ETCDCTL_API=3 \
ETCDCTL_CACERT=/etc/kubernetes/pki/etcd/ca.crt \
ETCDCTL_CERT=/etc/kubernetes/pki/etcd/server.crt \
ETCDCTL_KEY=/etc/kubernetes/pki/etcd/server.key \
etcdctl endpoint health"
sh: : command not found
Error: KeyFile and CertFile must both be present[key: /etc/kubernetes/pki/etcd/server.key, cert: ]
command terminated with exit code 128
markus@k8s-test:~$
`
doesnt work.. BUT
if i exec into the contaner it works just fine:
`
kubectl -n kube-system exec -it etcd-k8s-test.panday.local -- sh
sh-5.0# cd /etc/kubernetes/pki/etcd/
sh-5.0# echo *
ca.crt ca.key healthcheck-client.crt healthcheck-client.key peer.crt peer.key server.crt server.key
sh-5.0# export ETCDCTL_CACERT=/etc/kubernetes/pki/etcd/ca.crt
sh-5.0# export ETCDCTL_CERT=/etc/kubernetes/pki/etcd/server.crt
sh-5.0# export ETCDCTL_KEY=/etc/kubernetes/pki/etcd/server.key
sh-5.0# etcdctl endpoint health
127.0.0.1:2379 is healthy: successfully committed proposal: took = 78.42549ms
`
why is that? i also found out if i write everything into ONE line it works too:
markus@k8s-test:~$ kubectl -n kube-system exec -it etcd-k8s-test.panday.local -- sh -c "ETCDCTL_API=3 ETCDCTL_CACERT=/etc/kubernetes/pki/etcd/ca.crt ETCDCTL_CERT=/etc/kubernetes/pki/etcd/server.crt ETCDCTL_KEY=/etc/kubernetes/pki/etcd/server.key etcdctl endpoint health" 127.0.0.1:2379 is healthy: successfully committed proposal: took = 24.602875ms markus@k8s-test:~$
so why does the example from the "course" doesnt work ?
same with the next example from the "course" :
kubectl -n kube-system exec -it etcd-k8s-test.panday.local -- sh -c "ETCDCTL_API=3 --cert=./peer.crt --key=./peer.key --cacert=./ca.crt etcdctl --endpoints=https://127.0.0.1:2379 member list" sh: --cert=./peer.crt: No such file or directory command terminated with exit code 127
what i am curious. "-c" menas execute the command.. but you start with --cert ... what command is that? should not the the etcdcctl first? and if you just execute into the container it would end up in / i guess ... so when i change your example to
markus@k8s-test:~$ kubectl -n kube-system exec -it etcd-k8s-test.panday.local -- sh -c "ETCDCTL_API=3 cd /etc/kubernetes/pki/etcd/ && etcdctl --cert=./peer.crt --key=./peer.key --cacert=./ca.crt --endpoints=https://127.0.0.1:2379 member list" 28ef24cc2b5672b, started, k8s-test.panday.local, https://192.168.89.45:2380, https://192.168.89.45:2379, false markus@k8s-test:~$
so is this just on my side that i encounter things like that?
Best Answer
-
@mmaussner It simply doesn't see your cert like as if it is not in your command. In other words it sees your command as:
kubectl -n kube-system exec -it etcd-k8s-test.panday.local -- sh -c "ETCDCTL_API=3 \ ETCDCTL_CACERT=/etc/kubernetes/pki/etcd/ca.crt \ ETCDCTL_KEY=/etc/kubernetes/pki/etcd/server.key \ etcdctl endpoint health"
And for the second part of your questions -- yes, this is mistake in training course, but seems nobody cares of fixing these mistakes) That's why I stopped posting info about them at all)
0
Answers
-
@oleksazhel thanks for your answer. and a pitty if known mistakes arent fixed.
1 -
Hi @mmaussner,
There are CLI tools that do not like back-slashes part of multi-line commands, or while copying from the PDF lab guide may introduce invisible characters that cause these CLI issues. In these cases, removing the back-slashes and converting multi-line commands into single liners should work instead.
The
./peer.crt./peer.keyand./ca.crtassume a relative path, achieved by cd-ing into/etc/kubernetes/pki/etcd/. This can also be achieved by replacing the relative with the absolute paths such as/etc/kubernetes/pki/etcd/peer.crt...In addition, the
etcdctlcommand should be provided immediately after the API version 3 declaration, and not at the end
Regards,
-Chris0 -
I agree that the second example in the training materials need to be corrected.
Why would you use the peer cert instead of the original cert?
How could relative paths work if we're not cd'ing into any directory as part of the command?
And how could the second command ever work if --cert=... precedes etcdctl itself?
0 -
This was posted in August 2022, March 23 I still got the same error
doing the instructions on the pdf DOESN"T work....
got the same problems...
Udemy training that cost 12uds has fewer problems/errors than training 300usd... really?I guess this will me my first and last purchase on LF
0 -
Hi @andressasso84,
Can you provide the commands that do not work and the error outputs generated as a result?
Regards,
-Chris0 -
PDF:
student@cp: ̃$ kubectl -n kube-system exec -it etcd-cp -- sh \ #Same as before
-c "ETCDCTL_API=3 \ #Version to use
ETCDCTL_CACERT=/etc/kubernetes/pki/etcd/ca.crt \ #Pass the certificate authority
ETCDCTL_CERT=/etc/kubernetes/pki/etcd/server.crt \ #Pass the peer cert and key
ETCDCTL_KEY=/etc/kubernetes/pki/etcd/server.key \
etcdctl endpoint health" #The command to test the endpointandres@kubecp1:~$ kubectl -n kube-system exec -it etcd-kubecp1 -- sh
sh-5.1# -c "ETCDCTL_API=3 \ETCDCTL_CACERT=/etc/kubernetes/pki/etcd/ca.crt \
ETCDCTL_CERT=/etc/kubernetes/pki/etcd/server.crt \
ETCDCTL_KEY=/etc/kubernetes/pki/etcd/server.key \
etcdctl endpoint health"sh: -c: command not found
so that -c is causing troubles..
fixed by using mmaussner recommendation..
after fixing that I was able to continue with the lab updated CP to version v1.26.3
followed the steps on the working ...
checking from CPandres@kubecp1:~$ kubectl get node
NAME STATUS ROLES AGE VERSION
kubecp1 Ready control-plane 3d2h v1.26.3
worker1 Ready 2d23h v1.26.3
andres@kubecp1:~$but if want to do the same for the worker..
andres@worker1:~$ kubectl get node
E0323 04:04:03.498604 1390985 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E0323 04:04:03.499267 1390985 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E0323 04:04:03.501176 1390985 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E0323 04:04:03.502679 1390985 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E0323 04:04:03.504033 1390985 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
The connection to the server localhost:8080 was refused - did you specify the right host or port?no clue way is doing that... but again.. lab fail, now I have to waste time and troubleshoot... a good way on learning... but I would hope that the lab works ...
0 -
Hi @andressasso84,
As a result of how the Kubernetes environment is configured for this lab, the
kubectlcommand is expected to fail from the worker node. The.kube/configfile is not set on the worker, and I do not believe there is a step in the lab guide presenting a successful run from the worker node either.Regards,
-Chris0
Categories
- All Categories
- 177 LFX Mentorship
- 177 LFX Mentorship: Linux Kernel
- 750 Linux Foundation IT Professional Programs
- 373 Cloud Engineer IT Professional Program
- 169 Advanced Cloud Engineer IT Professional Program
- 74 DevOps IT Professional Program - Discontinued
- 4 DevOps & GitOps IT Professional Program
- 99 Cloud Native Developer IT Professional Program
- 7.6K Training Courses & Learning Paths
- 1 AI & ML Training
- 1 Blockchain & Decentralized Identity Training
- 5 Cloud & Containers Training
- 1 Cybersecurity Training
- 2 DevOps & Site-Reliability Training
- 1 Linux Kernel Development Training
- 1 Networking Training
- 2 Open Source Best Practice Training
- 1 System Administration Training
- 1 System Engineering Training
- 1 Web & Application Development Training
- 792 Hardware
- 202 Drivers
- 68 I/O Devices
- 37 Monitors
- 95 Multimedia
- 173 Networking
- 91 Printers & Scanners
- 87 Storage
- 769 Linux Distributions
- 81 Debian
- 68 Fedora
- 22 Linux Mint
- 13 Mageia
- 24 openSUSE
- 150 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 465 Linux System Administration
- 31 Cloud Computing
- 73 Command Line/Scripting
- Github systems admin projects
- 98 Linux Security
- 78 Network Management
- 101 System Management
- 46 Web Management
- 106 Mobile Computing
- 18 Android
- 73 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 392 Off Topic
- 121 Introductions
- 181 Small Talk
- 29 Study Material
- 955 Programming and Development
- 310 Kernel Development
- 627 Software Development
- 984 Software
- 376 Applications
- 182 Command Line
- 5 Compiling/Installing
- 68 Games
- 317 Installation
- Archived
- 2 LFD140 Class Forum
- 1.4K LFS258 Class Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)