Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

k8s #13

Open
gobomb opened this issue Jan 7, 2020 · 26 comments
Open

k8s #13

gobomb opened this issue Jan 7, 2020 · 26 comments

Comments

@gobomb
Copy link
Owner

gobomb commented Jan 7, 2020

kubectl cluster-info dump | grep -m 1 service-cluster-ip-range
kubectl cluster-info dump | grep -m 1 cluster-cidr

https://stackoverflow.com/questions/44190607/how-do-you-find-the-cluster-service-cidr-of-a-kubernetes-cluster

@gobomb
Copy link
Owner Author

gobomb commented Feb 28, 2020

网络调试镜像 praqma/network-multitool

@gobomb
Copy link
Owner Author

gobomb commented Feb 28, 2020

国内Mirror sites

quay.io -> quay-mirror.qiniu.com

gcr.io -> gcr.azk8s.cn

@gobomb
Copy link
Owner Author

gobomb commented Apr 7, 2020

@gobomb
Copy link
Owner Author

gobomb commented Apr 7, 2020

cient-go 是从 k8s 代码中抽出来的一个客户端工具,Informer 是 client-go 中的核心工具包,已经被 kubernetes 中众多组件所使用。所谓 Informer,其实就是一个带有本地缓存和索引机制的、可以注册 EventHandler 的 client,本地缓存被称为 Store,索引被称为 Index。使用 informer 的目的是为了减轻 apiserver 数据交互的压力而抽象出来的一个 cache 层, 客户端对 apiserver 数据的 "读取" 和 "监听" 操作都通过本地 informer 进行。Informer 实例的Lister()方法可以直接查找缓存在本地内存中的数据。

Informer 的主要功能:

  • 同步数据到本地缓存

  • 根据对应的事件类型,触发事先注册好的 ResourceEventHandler

https://mp.weixin.qq.com/s?__biz=MzAwNzcyMDY5Mg==&mid=2648900075&idx=1&sn=cee6ba44c26310ea68dd091df21eb8dd

@gobomb
Copy link
Owner Author

gobomb commented Apr 14, 2020

访问docker容器网络命名空间

pid=$(docker inspect -f '{{.State.Pid}}' ${container_id})
mkdir -p /var/run/netns/
ln -sfT /proc/$pid/ns/net /var/run/netns/[container_id]
ip netns exec [container_id] ip a

https://www.thegeekdiary.com/how-to-access-docker-containers-network-namespace-from-host/

#7 (comment)

@gobomb
Copy link
Owner Author

gobomb commented May 21, 2020

Kubernetes uses the term list to describe returning a collection of resources to distinguish from retrieving a single resource which is usually called a get.

@gobomb
Copy link
Owner Author

gobomb commented May 26, 2020

@gobomb
Copy link
Owner Author

gobomb commented Jun 17, 2020

@gobomb
Copy link
Owner Author

gobomb commented Jul 14, 2020

https://www.cnblogs.com/gaorong/p/10925480.html

k8s 问题排查一例

@gobomb
Copy link
Owner Author

gobomb commented Jul 21, 2020

@gobomb
Copy link
Owner Author

gobomb commented Aug 10, 2020

LowerDir: these are the read-only layers of an overlay filesystem. For docker, these are the image layers assembled in order.

UpperDir: this is the read-write layer of an overlay filesystem. For docker, that is the equivalent of the container specific layer that contains changes made by that container.

WorkDir: this is a required directory for overlay, it needs an empty directory for internal use.

MergedDir: this is the result of the overlay filesystem. Docker effectively chroot's into this directory when running the container.

https://stackoverflow.com/questions/56550890/docker-image-merged-diff-work-lowerdir-components-of-graphdriver

@gobomb
Copy link
Owner Author

gobomb commented Aug 26, 2020

https://zhuanlan.zhihu.com/p/59544387

tidb operator 如何使用优雅关闭

@gobomb
Copy link
Owner Author

gobomb commented Aug 26, 2020

https://github.blog/2019-11-21-debugging-network-stalls-on-kubernetes/

Debugging network stalls on Kubernetes

@gobomb
Copy link
Owner Author

gobomb commented Aug 26, 2020

@gobomb
Copy link
Owner Author

gobomb commented Aug 27, 2020

https://www.bluematador.com/blog/kubernetes-deployments-rolling-update-configuration

stragegy 可设为 rollingupdate 或者 recreate

@gobomb
Copy link
Owner Author

gobomb commented Sep 9, 2020

在给dockerd设置代理的情况下,要记得设置 Bypass proxy settings for these hosts & domains,否则push镜像时会报错:
error parsing HTTP 404 response body: unexpected end of JSON input: ""

@gobomb
Copy link
Owner Author

gobomb commented Oct 6, 2020

https://mp.weixin.qq.com/s/-Kau28Q5y23GyGWECWlhVg

client-go 中 index 相关源码

@gobomb
Copy link
Owner Author

gobomb commented Feb 18, 2021

openshift v2.11.0+1cd89d4-542
kubernetes v0.11.0+d4cacc0

openshift 在发布deployment时,默认会给pod加node-role.kubernetes.io/compute=true的nodeselector使得pod调度到计算节点上。

可修改namespace的annotation,覆盖默认nodeselector:oc annotate --overwrite namespace default openshift.io/node-selector='region=infra'

@gobomb
Copy link
Owner Author

gobomb commented Mar 2, 2021

https://zhuanlan.zhihu.com/p/37217575

写了类似的bug,难怪每次报错:

Status:Failure,Message:The resourceVersion for the provided watch is too old.,Reason:Expired,Details:nil,Code:410,}

@gobomb
Copy link
Owner Author

gobomb commented Mar 3, 2021

https://mp.weixin.qq.com/s/jWH7jVxj20bmc60_C-w9wQ

patch 和 update

@gobomb
Copy link
Owner Author

gobomb commented Mar 3, 2021

@gobomb
Copy link
Owner Author

gobomb commented Mar 3, 2021

用dlv调试容器内go进程

dlv attach $(pidof $YOURPOCESS) $(docker inspect -f '{{.GraphDriver.Data.MergedDir}}{{.Path}}' $CONTAINERID)

$YOURPOCESS 为进程名

$CONTAINERID 为容器ID

@gobomb
Copy link
Owner Author

gobomb commented Mar 10, 2021

crd定义yaml中设置kubectl能够显示的列

spec:
  additionalPrinterColumns:
  - JSONPath: .status.phase
    name: State
    type: string
  - JSONPath: .metadata.creationTimestamp
    name: CreateTime
    type: string
  group: cloudapp.cloudtogo.cn
  names:
  .....

@gobomb
Copy link
Owner Author

gobomb commented Mar 18, 2021

https://blog.csdn.net/u013276277/article/details/103404653

client-go watch 返回的 chan 被关闭问题

@gobomb
Copy link
Owner Author

gobomb commented Mar 22, 2021

https://mp.weixin.qq.com/s/jWH7jVxj20bmc60_C-w9wQ

k8s update与apply

@gobomb
Copy link
Owner Author

gobomb commented Mar 22, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant