Open13

Kubernetesコントリビューション

ピン留めされたアイテム
bells17bells17

まずはこれを一通り読む

https://www.kubernetes.dev/docs/onboarding/

開発にあたっての基本情報

https://www.kubernetes.dev/docs/guide/contributing/

https://github.com/kubernetes/community/blob/master/contributors/devel/development.md?plain=0

PRの流れ関連

https://www.kubernetes.dev/docs/guide/pull-requests/

https://www.kubernetes.dev/docs/guide/github-workflow/

https://www.kubernetes.dev/docs/guide/coding-convention/

https://www.kubernetes.dev/docs/contributor-cheatsheet/

その他お役立ち情報

テスト関連

https://www.kubernetes.dev/docs/onboarding/06-testing/

https://github.com/kubernetes/community/blob/master/contributors/devel/development.md?plain=0

https://github.com/kubernetes/community/blob/master/contributors/devel/sig-testing/integration-tests.md?plain=0

https://github.com/kubernetes/community/blob/master/contributors/devel/sig-testing/e2e-tests-kubetest2.md?plain=0

https://github.com/kubernetes/community/blob/master/contributors/devel/sig-testing/e2e-tests.md?plain=0

https://github.com/kubernetes-sigs/kubetest2

update & verify

自動生成系はこれでOK

make update

verifyは下記でできる

make verify

ただクッソ時間かかるので基本は↓みたいな感じで必要なやつだけ実行すると良さげ

make verify WHAT="gofmt typecheck"
bells17bells17
  • issueやPRでのやり取りにおける合意形成した内容を忘れないようにする
    • TODO やり取りの際に意図とかをもう少し気軽に確認できるようにしたい
  • PRのマージまでは時間がかかることが多いので、それに伴ってrebaseによるコンフリクトも多く発生するが、それは頑張って解消するしかなさそう
bells17bells17

kube-cross

TODO: kube-crossの用途

https://github.com/kubernetes/release/blob/master/images/build/cross/default/Dockerfile

https://github.com/kubernetes/release/pull/1258

$ docker history --format=json --no-trunc registry.k8s.io/build-image/kube-cross:v1.30.0-go1.22.2-bullseye.0 | jq .
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:57:29+09:00",
  "CreatedBy": "ENTRYPOINT []",
  "CreatedSince": "2 weeks ago",
  "ID": "sha256:2c8b152ffe12eea09eaca5508c32440bf26249c0db2b226c02e6ca73a4311606",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:57:29+09:00",
  "CreatedBy": "RUN |2 TARGETPLATFORM=linux/arm64 DEBIAN_FRONTEND=noninteractive /bin/sh -c apt-get -qqy remove       wget     && apt-get clean     && rm -rf --         /var/lib/apt/lists/* # buildkit",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "594kB"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:57:17+09:00",
  "CreatedBy": "RUN |2 TARGETPLATFORM=linux/arm64 DEBIAN_FRONTEND=noninteractive /bin/sh -c for i in {1..5}; do GOPROXY=\"direct\" go install golang.org/x/tools/cmd/cover@latest && break || sleep 15; done      && for i in {1..5}; do GOPROXY=\"direct\" go install golang.org/x/tools/cmd/goimports@latest && break || sleep 15; done      && go clean -cache # buildkit",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "186MB"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:50:14+09:00",
  "CreatedBy": "RUN |2 TARGETPLATFORM=linux/arm64 DEBIAN_FRONTEND=noninteractive /bin/sh -c mkdir $TMPDIR   && chmod a+rwx $TMPDIR   && chmod o+t $TMPDIR # buildkit",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:50:14+09:00",
  "CreatedBy": "ENV TMPDIR=/tmp.k8s",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:50:14+09:00",
  "CreatedBy": "RUN |2 TARGETPLATFORM=linux/arm64 DEBIAN_FRONTEND=noninteractive /bin/sh -c targetArch=$(echo $TARGETPLATFORM | cut -f2 -d '/')   && if [ ${targetArch} = \"amd64\" ]; then   ZIPNAME=\"protoc-${PROTOBUF_VERSION}-linux-x86_64.zip\"; elif [ ${targetArch} = \"arm64\" ]; then   ZIPNAME=\"protoc-${PROTOBUF_VERSION}-linux-aarch_64.zip\"; elif [ ${targetArch} = \"ppc64le\" ]; then   ZIPNAME=\"protoc-${PROTOBUF_VERSION}-linux-ppcle_64.zip\"; elif [ ${targetArch} = \"s390x\" ]; then   ZIPNAME=\"protoc-${PROTOBUF_VERSION}-linux-s390_64.zip\"; fi   && mkdir /tmp/protoc && cd /tmp/protoc   && wget \"https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/${ZIPNAME}\"   && unzip \"${ZIPNAME}\"   && chmod -R +rX /tmp/protoc   && cp -pr bin /usr/local   && cp -pr include /usr/local   && rm -rf /tmp/protoc   && protoc --version # buildkit",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "8.26MB"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:50:12+09:00",
  "CreatedBy": "ENV PROTOBUF_VERSION=23.4",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:50:12+09:00",
  "CreatedBy": "RUN |2 TARGETPLATFORM=linux/arm64 DEBIAN_FRONTEND=noninteractive /bin/sh -c targetArch=$(echo $TARGETPLATFORM | cut -f2 -d '/')   && if [ ${targetArch} = \"ppc64le\" ] || [ ${targetArch} = \"s390x\" ]; then     echo \"deb http://ports.ubuntu.com/ubuntu-ports/ xenial main\" > /etc/apt/sources.list.d/ports.list     && apt-key adv --no-tty --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 3B4FE6ACC0B21F32     && apt-get update     && apt-get install -y build-essential; fi # buildkit",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:50:12+09:00",
  "CreatedBy": "RUN |2 TARGETPLATFORM=linux/arm64 DEBIAN_FRONTEND=noninteractive /bin/sh -c targetArch=$(echo $TARGETPLATFORM | cut -f2 -d '/')   && if [ ${targetArch} = \"arm64\" ]; then     echo \"deb http://ports.ubuntu.com/ubuntu-ports/ xenial main\" > /etc/apt/sources.list.d/ports.list     && apt-key adv --no-tty --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 3B4FE6ACC0B21F32     && apt-get update     && apt-get install -y build-essential gcc-x86-64-linux-gnu; fi # buildkit",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "542MB"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:47:50+09:00",
  "CreatedBy": "RUN |2 TARGETPLATFORM=linux/arm64 DEBIAN_FRONTEND=noninteractive /bin/sh -c targetArch=$(echo $TARGETPLATFORM | cut -f2 -d '/')   && if [ ${targetArch} = \"amd64\" ]; then     echo \"deb http://archive.ubuntu.com/ubuntu xenial main universe\" > /etc/apt/sources.list.d/cgocrosscompiling.list     && apt-key adv --no-tty --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 3B4FE6ACC0B21F32     && apt-get update     && apt-get install -y build-essential mingw-w64     && for platform in ${KUBE_DYNAMIC_CROSSPLATFORMS}; do apt-get install -y crossbuild-essential-${platform}; done fi # buildkit",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:47:49+09:00",
  "CreatedBy": "RUN |2 TARGETPLATFORM=linux/arm64 DEBIAN_FRONTEND=noninteractive /bin/sh -c apt-get -q update     && apt-get install -qqy         apt-utils         file         jq         patch         rsync         unzip         iproute2 # buildkit",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "35.1MB"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:46:59+09:00",
  "CreatedBy": "RUN |2 TARGETPLATFORM=linux/arm64 DEBIAN_FRONTEND=noninteractive /bin/sh -c targetArch=$(echo $TARGETPLATFORM | cut -f2 -d '/')     && if [ ${targetArch} = \"amd64\" ]; then     for platform in ${KUBE_CROSSPLATFORMS}; do GOOS=${platform%/*} GOARCH=${platform##*/} go install std; done     && go clean -cache; fi # buildkit",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:46:59+09:00",
  "CreatedBy": "ENV KUBE_CROSSPLATFORMS=linux/386   linux/arm linux/arm64   linux/ppc64le   linux/s390x   darwin/amd64   windows/amd64 windows/386",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:46:59+09:00",
  "CreatedBy": "ENV KUBE_DYNAMIC_CROSSPLATFORMS=arm64   armhf   i386   ppc64el   s390x",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:46:59+09:00",
  "CreatedBy": "ENV GOARM=7",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:46:59+09:00",
  "CreatedBy": "ARG DEBIAN_FRONTEND=noninteractive",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-05T01:46:59+09:00",
  "CreatedBy": "ARG TARGETPLATFORM",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-04T01:03:48+09:00",
  "CreatedBy": "WORKDIR /go",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-04T01:03:48+09:00",
  "CreatedBy": "RUN /bin/sh -c mkdir -p \"$GOPATH/src\" \"$GOPATH/bin\" && chmod -R 1777 \"$GOPATH\" # buildkit",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-04T01:03:48+09:00",
  "CreatedBy": "COPY /usr/local/go/ /usr/local/go/ # buildkit",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "220MB"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-04T01:03:48+09:00",
  "CreatedBy": "ENV PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-04T01:03:48+09:00",
  "CreatedBy": "ENV GOPATH=/go",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-04T01:03:48+09:00",
  "CreatedBy": "ENV GOTOOLCHAIN=local",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-04T01:03:48+09:00",
  "CreatedBy": "ENV GOLANG_VERSION=1.22.2",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "buildkit.dockerfile.v0",
  "CreatedAt": "2024-04-04T01:03:48+09:00",
  "CreatedBy": "RUN /bin/sh -c set -eux;  apt-get update;  apt-get install -y --no-install-recommends   g++   gcc   libc6-dev   make   pkg-config  ;  rm -rf /var/lib/apt/lists/* # buildkit",
  "CreatedSince": "2 weeks ago",
  "ID": "<missing>",
  "Size": "209MB"
}
{
  "Comment": "",
  "CreatedAt": "2024-03-12T10:26:18+09:00",
  "CreatedBy": "/bin/sh -c set -eux;  apt-get update;  apt-get install -y --no-install-recommends   git   mercurial   openssh-client   subversion     procps  ;  rm -rf /var/lib/apt/lists/*",
  "CreatedSince": "5 weeks ago",
  "ID": "<missing>",
  "Size": "150MB"
}
{
  "Comment": "",
  "CreatedAt": "2024-03-12T10:26:03+09:00",
  "CreatedBy": "/bin/sh -c set -eux;  apt-get update;  apt-get install -y --no-install-recommends   ca-certificates   curl   gnupg   netbase   wget  ;  rm -rf /var/lib/apt/lists/*",
  "CreatedSince": "5 weeks ago",
  "ID": "<missing>",
  "Size": "28.3MB"
}
{
  "Comment": "",
  "CreatedAt": "2024-03-12T09:45:44+09:00",
  "CreatedBy": "/bin/sh -c #(nop)  CMD [\"bash\"]",
  "CreatedSince": "5 weeks ago",
  "ID": "<missing>",
  "Size": "0B"
}
{
  "Comment": "",
  "CreatedAt": "2024-03-12T09:45:43+09:00",
  "CreatedBy": "/bin/sh -c #(nop) ADD file:7cb312b5f676a37f5c3172be6eb95e30986e5da0dcf21985d2176f8a9a037012 in / ",
  "CreatedSince": "5 weeks ago",
  "ID": "<missing>",
  "Size": "118MB"
}
bells17bells17

hack

golancilint関連

$ make verify # verify全般実行
$ ./hack/verify-golangci-lint.sh # golangcilint実行

hack/logcheck.conf を更新した場合の反映

$ ./hack/update-golangci-lint-config.sh

stagingディレクトリ以下を変更した場合にvendorに反映する方法

$ ./hack/update-vendor.sh
bells17bells17

よく使うコマンド

upstreamの取り込み

$ git fetch upstream
$ git rebase upstream/master

kube-crossコンテナでmakeなどの各種コマンドなどを実行する(ローカルでうまくいかないときに実行する)

https://github.com/kubernetes/kubernetes/tree/master/build

$ ./build/run.sh <コマンド>
$ ./build/run.sh make verify

Macでgo installなどがうまくいかない場合

GOOSを指定する

$ GOOS=darwin ./hack/verify-golangci-lint.sh

指定パッケージのユニットテストの実行方法

make test WHAT=pkg/volume/util/
bells17bells17

ツール類

Kubernetesプロジェクトに対するコントリビューションが見れるサイト

https://contribcard.clotributor.dev/

CNCF所属?のリポジトリのissueを横断的に探せるやつ

https://clotributor.dev/search?good_first_issue=true

devstat(コントリビューション数とか見れるやつ)

https://k8s.devstats.cncf.io/d/66/developer-activity-counts-by-companies?orgId=1&var-period_name=Last decade&var-metric=contributions&var-repogroup_name=All&var-repo_name=kubernetes&var-country_name=All&var-companies=3-shake

prow status(主に自分のPR一覧を見たりprow command探したり)

https://prow.k8s.io/