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.key
and./ca.crt
assume 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
etcdctl
command should be provided immediately after the API version 3 declaration, and not at the endRegards,
-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
kubectl
command is expected to fail from the worker node. The.kube/config
file 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
- 50 LFX Mentorship
- 103 LFX Mentorship: Linux Kernel
- 576 Linux Foundation IT Professional Programs
- 304 Cloud Engineer IT Professional Program
- 125 Advanced Cloud Engineer IT Professional Program
- 53 DevOps Engineer IT Professional Program
- 61 Cloud Native Developer IT Professional Program
- 5 Express Training Courses
- 5 Express Courses - Discussion Forum
- 2K Training Courses
- 19 LFC110 Class Forum
- 7 LFC131 Class Forum
- 27 LFD102 Class Forum
- 157 LFD103 Class Forum
- 20 LFD121 Class Forum
- 1 LFD137 Class Forum
- 61 LFD201 Class Forum
- 1 LFD210 Class Forum
- LFD210-CN Class Forum
- 1 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum
- LFD237 Class Forum
- 23 LFD254 Class Forum
- 611 LFD259 Class Forum
- 105 LFD272 Class Forum
- 1 LFD272-JP クラス フォーラム
- 1 LFD273 Class Forum
- 2 LFS145 Class Forum
- 24 LFS200 Class Forum
- 739 LFS201 Class Forum
- 1 LFS201-JP クラス フォーラム
- 11 LFS203 Class Forum
- 75 LFS207 Class Forum
- 300 LFS211 Class Forum
- 54 LFS216 Class Forum
- 47 LFS241 Class Forum
- 41 LFS242 Class Forum
- 37 LFS243 Class Forum
- 11 LFS244 Class Forum
- 36 LFS250 Class Forum
- 1 LFS250-JP クラス フォーラム
- LFS251 Class Forum
- 140 LFS253 Class Forum
- LFS254 Class Forum
- 1.1K LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 93 LFS260 Class Forum
- 132 LFS261 Class Forum
- 33 LFS262 Class Forum
- 80 LFS263 Class Forum
- 15 LFS264 Class Forum
- 11 LFS266 Class Forum
- 18 LFS267 Class Forum
- 17 LFS268 Class Forum
- 23 LFS269 Class Forum
- 203 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- LFS274 Class Forum
- LFS281 Class Forum
- 234 LFW211 Class Forum
- 172 LFW212 Class Forum
- 7 SKF100 Class Forum
- SKF200 Class Forum
- 902 Hardware
- 219 Drivers
- 74 I/O Devices
- 44 Monitors
- 115 Multimedia
- 209 Networking
- 101 Printers & Scanners
- 85 Storage
- 763 Linux Distributions
- 88 Debian
- 66 Fedora
- 15 Linux Mint
- 13 Mageia
- 24 openSUSE
- 142 Red Hat Enterprise
- 33 Slackware
- 13 SUSE Enterprise
- 357 Ubuntu
- 479 Linux System Administration
- 41 Cloud Computing
- 70 Command Line/Scripting
- Github systems admin projects
- 95 Linux Security
- 78 Network Management
- 108 System Management
- 49 Web Management
- 68 Mobile Computing
- 23 Android
- 30 Development
- 1.2K New to Linux
- 1.1K Getting Started with Linux
- 537 Off Topic
- 131 Introductions
- 217 Small Talk
- 21 Study Material
- 826 Programming and Development
- 278 Kernel Development
- 514 Software Development
- 928 Software
- 260 Applications
- 184 Command Line
- 3 Compiling/Installing
- 76 Games
- 316 Installation
- 62 All In Program
- 62 All In 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)