2019 年 7 月手记
Kubernetes
api conventions
kube node lease
kube node lease 用来改善 kubelet 定时更新节点状态对 etcd 造成的压力。
https://containers.goffinet.org/k8s/kubectlget.html#what-about-kube-node-lease
https://github.com/kubernetes/enhancements/blob/master/keps/sig-node/0009-node-heartbeat.md
https://kubernetes.io/docs/concepts/architecture/nodes/#node-controller
https://github.com/kubernetes-sigs/kubespray/blob/master/docs/kubernetes-reliability.md
Finalizers
https://book-v1.book.kubebuilder.io/beyond_basics/using_finalizers.html
controller history
ControllerRevision 是为 StatefulSet 和 DaemonSet 保存历史的资源类型。因为设计得比较通用,第三方控制器 + CRD 也可以借助它来实现版本管理。
client-go informer
https://github.com/kubernetes/sample-controller/blob/master/docs/controller-client-go.md
kubebuilder
kubebuilder 是开发第三方 controller 或 operator 的代码框架生成工具。它的实现基于 controller-runtime 这个项目。
Create Kubernetes Cluster
使用 kubeadm 快速搭建一个可用的开发集群:
1 | kubectl apply -f https://docs.projectcalico.org/v3.8/manifests/calico.yaml |
KubeCon 2019 Videos
https://www.youtube.com/watch?v=5yKheFRMflQ&list=PLj6h78yzYM2Njj5PvNc4Mtcril2YyR95d
阿里技术
基于多租户的虚拟集群
https://drive.google.com/file/d/1DX3jBwueEpSRhJ6n3VcqS1S3GDVvhF1B/view
https://docs.google.com/document/d/1EELeVaduYZ65j4AXg9bp3Kyn38GKDU5fAJ5LFcxt2ZU/edit
容器迁移
CRI
Container Runtime Interface (CRI) CLI
Storage
Flex Volume
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-storage/flexvolume.md
CSI
Kubernetes Handbook
https://jimmysong.io/kubernetes-handbook/
Kubernetes testing
https://jimmysong.io/kubernetes-handbook/develop/testing.html
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-testing/testing.md
integration testing
e2e testing
https://kubernetes.io/blog/2019/03/22/kubernetes-end-to-end-testing-for-everyone/
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-testing/e2e-tests.md
https://www.cnblogs.com/jinsdu/p/7465434.html
https://github.com/onsi/ginkgo
可以参考的项目
deletion and garbage collection
这篇文章 介绍了 kubernetes 的删除和垃圾回收机制。
ingress
Useful Commands
查看 control-plane 状态
1 | kubectl get componentstatus |
Container
RunC 简介
docker registry self-signed certificates
自建 docker registry 自签名方法:
https://docs.docker.com/registry/insecure/
容器安全性
Running Docker Containers as Current Host User
Useful Commands
debug container
通过以下命令可以很方便的调试容器网络:
1 | sudo nsenter -t <container-pid> -n ip addr |
start mongodb locally
1 | docker run -p 27017:27017 -v $PWD/db:/data/db -d mongo:3.2 |
Golang
go modules (vgo)
go modules 已经逐渐取代其他依赖管理工具,很多社区项目都在逐步向 go modules 迁移。
go modules with kubernetes 的坑
使用 go modules 导入 k8s.io/kubernetes
主库会有问题,因为主库的 go.mod
文件里 replace 了一大堆依赖,官方给的建议 是在自己的 go.mod
文件里再次 replace 会正确的版本,或者干脆不要依赖主库。
golang 内存逃逸
golang 测试
Package test
Productive
StarUML Crack
https://gist.github.com/trandaison/40b1d83618ae8e3d2da59df8c395093a#gistcomment-2723165
Dictionary Extension
用 DictUnifier(已改名为 mac-dictionary-kit)可以将 stardict 词典格式转换为 Apple Dict 格式。
转换教程参考:
- https://www.douban.com/group/topic/9591106/
- https://github.com/tsoliangwu0130/my-macos/blob/master/misc/dictunifier-stardict.md
PyGlossary 是另外一种词典转换工具,不过需要在 Apple Developer Downloads 单独下载 Additional Tools for Xcode.
词典转换后可能会有 css 显示问题,可以参考:
禁用 .DS_Store
如果在 macOS 的 Finder 里访问网络文件系统(比如 samba),打开目录是会自动在目录下生成 .DS_Store
来存储一些元信息(标签、文件夹颜色、排序等等),这个在其他系统上看起来就非常不顺眼,因此可以通过下面的命令禁用:
1 | defaults write com.apple.desktopservices DSDontWriteNetworkStores true |
但是这个命令只对网络存储有用,对于本地磁盘还是会生成 .DS_Store
文件,暂时没有方便的办法禁用。
Jetbrains back/forward with mouse
有的鼠标有 Button4 和 Button5 可以在浏览代码时很方便地前进和后退,macOS 系统,在 Visual Studio Code 上正常,但在 Jetbrains 系的 IDE 上默认却是跳转到行首和行尾,解决方法是修改 Button4 和 Button5 默认的键盘快捷键。可以参考这个方法修改。
Vagrant + KVM
KVM 比 VirtualBox 的性能更好,在 Linux 环境下推荐使用:
https://medium.com/@gauthierleonard/kvm-machines-for-vagrant-on-archlinux-1d8863344cb7
https://docs.cumulusnetworks.com/display/VX/Vagrant+and+Libvirt+with+KVM+or+QEMU
https://gist.github.com/yuanying/924ce2ce61b75ab818b5
Windows 10 + Ubuntu 18.04
在 MacOS 上刻录镜像
https://www.cybrary.it/0p3n/macos-terminal-create-bootable-usb-iso-using-dd/
Ubuntu Installer 无法识别 GPT 分区
https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/disabling-secure-boot
https://www.technorms.com/45538/disable-enable-secure-boot-asus-motherboard-uefi-bios-utility
NVMe 安装 Ubuntu
https://ubuntuforums.org/showthread.php?t=2390475
https://ubuntu-mate.community/t/cant-see-nvme-m-2-drive-for-fresh-install/18463/3
VSC Remote
使用 VSC Remote 可以方便地在 Windows 或者 macOS 下利用 ssh 进行 Linux 环境远程开发和调试。需要安装 Visual Studio Code insiders 版本。
Git
change author of commits
https://makandracards.com/makandra/1717-git-change-author-of-a-commit
grep logs
有时候需要确认某个 PR 或者 commit 有没有合入特定版本或者分支,可以用下面的命令:
1 | git log <branch-or-tag-name> --since 3.weeks --grep <pattern> |
git status 显示 UTF-8 字符
1 | git config --global core.quotepath false |
Bazel
Bazel 是 Google 的构建工具,CMake 或者 Makefile 的替代品。
jq
json 的命令行解析工具。参考:https://stedolan.github.io/jq/tutorial/
Shell
Others
服务名与端口号映射
https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
Flink
https://segmentfault.com/a/1190000016901447
CSS
一个学习 css 的网站,支持边学边练:https://developer.mozilla.org/en-US/docs/Web/CSS/white-space