ARST打卡第191周[191/521]

Algorithm

lc2351_第一个出现两次的字母

1
2
3
4
5
6
7
8
9
10
11
12
// 直接简单map记录遍历就没了,签到题
func repeatedCharacter(s string) byte {
char2index := make(map[byte]int)
for i, runeC := range s {
c := byte(runeC)
if _, ok := char2index[c]; ok {
return c
}
char2index[c] = i
}
return ' '
}

Review

Microservice Architectures

这个文档非常有用,一定要看一下,讲述了发展的根因和历程以及简介,非常有帮助

Microservices are no silver bullet, but may be the best way forward for
• large web systems
• built by professional software engineers

Tips

How to install specific version of Kubernetes?

Share-kubeadm安装k8s的一些避坑建议

避免90%的问题的关键

k8s官网的安装文章中讲解一些版本依赖关系

因此安装指定版本的k8s,就需要安装适应版本kubeadm!!!

拿1.22版本举例子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
root@arm:~# curl -s https://packages.cloud.google.com/apt/dists/kubernetes-xenial/main/binary-amd64/Packages | grep Version | awk '{print $2}' | grep 1.22.2
1.22.2-00
1.22.2-00
1.22.2-00
root@arm:~# curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list && \
sudo apt-get update -q && \
sudo apt-get install -qy kubelet=1.22.2-00 kubectl=1.22.2-00 kubeadm=1.22.2-00
OK
deb http://apt.kubernetes.io/ kubernetes-xenial main
Get:2 http://ports.ubuntu.com/ubuntu-ports bionic-security InRelease [88.7 kB]
Hit:3 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports bionic InRelease
Get:4 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports bionic-updates InRelease [88.7 kB]
Get:1 https://packages.cloud.google.com/apt kubernetes-xenial InRelease [9383 B]
Get:5 https://packages.cloud.google.com/apt kubernetes-xenial/main arm64 Packages [60.8 kB]
Get:6 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports bionic-backports InRelease [83.3 kB]
Fetched 331 kB in 2s (187 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following held packages will be changed:
kubeadm kubectl kubelet
The following packages will be DOWNGRADED:
kubeadm kubectl kubelet
0 upgraded, 0 newly installed, 3 downgraded, 0 to remove and 34 not upgraded.
E: Packages were downgraded and -y was used without --allow-downgrades.

# 后面试了继续,需要 `--allow-downgrades --allow-change-held-packages` (对于之前安装过高版本并且hold过的,新安装的加不加都行)
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list && \
sudo apt-get update -q && \
sudo apt-get install -qy kubelet=1.22.2-00 kubectl=1.22.2-00 kubeadm=1.22.2-00 \
--allow-downgrades --allow-change-held-packages

# 舒服了,终于变成指定版本了,赶紧hold
root@arm:~# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.2", GitCommit:"8b5a19147530eaac9476b0ab82980b4088bbc1b2", GitTreeState:"clean", BuildDate:"2021-09-15T21:37:34Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/arm64"}
root@arm:~# apt-mark hold kubelet kubeadm kubectl
kubelet set on hold.
kubeadm set on hold.
kubectl set on hold.

# 再来初始化---处理一下小问题,然后开始安装,等待完成
root@arm:~# kubeadm init \
--kubernetes-version v1.22.2 \
--pod-network-cidr=192.168.0.0/16

避免剩下的9%的问题

kubeadm init第一次之后,后续需要kubeadm reset,rm /var/lib/etcd进行清理

最后1%的问题避免

kubeadm init --help,多使用help查看自己需要使用的参数的含义,搞清楚含义才能真正地避免问题