Skip to content

Latest commit

ย 

History

History
1220 lines (955 loc) ยท 46.6 KB

File metadata and controls

1220 lines (955 loc) ยท 46.6 KB

็ฌฌ32่Š‚ kubernetes ็›ฎๅฝ•็ป“ๆž„


โค๏ธ๐Ÿ’•๐Ÿ’•ๆ–ฐๆ—ถไปฃๆ‹ฅๆŠฑไบ‘ๅŽŸ็”Ÿ๏ผŒไบ‘ๅŽŸ็”Ÿๅ…ทๆœ‰็Žฏๅขƒ็ปŸไธ€ใ€ๆŒ‰้œ€ไป˜่ดนใ€ๅณๅผ€ๅณ็”จใ€็จณๅฎšๆ€งๅผบ็‰น็‚นใ€‚Myblog:http://nsddd.top


[TOC]

ๅˆ†็ฑป

Kubernetes ๆ˜ฏGo่ฏญ่จ€ๅผ€ๅ‘็š„๏ผŒ็›ธๅฏนๆฅ่ฏดๅคง้ƒจๅˆ†็ป“ๆž„่ฟ˜ๆ˜ฏๅพˆๆธ…ๆ™ฐ็š„ใ€‚

Kubernetes็š„ไปฃ็ ้ƒฝๅœจ kubernetes็›ฎๅฝ•ไธ‹๏ผŒๅฆ‚ๅ›พ๏ผŒๆ นๆฎๅŠŸ่ƒฝไธป่ฆๅˆ†ๆˆไปฅไธ‹ๅ‡ ็ฑป๏ผš 1ใ€ๆ–‡ๆกฃ็ฑป๏ผˆapiใ€docsใ€logo๏ผ‰ 2ใ€ๅทฅๅ…ท็ฑป๏ผˆbuildใ€clusterใ€Godepsใ€hackใ€stagingใ€translations๏ผ‰ 3ใ€ไปฃ็ ็ฑป๏ผˆcmdใ€pkgใ€pluginใ€testใ€third_party๏ผ‰

ๅทฅๅ…ท็ฑปไธป่ฆ็”จๅˆฐ็š„ build็›ฎๅฝ•ไธ‹็š„ๆ–‡ไปถ๏ผŒ่‡ชๅทฑๅŠจๆ‰‹็ผ–่ฏ‘็š„ๆ—ถๅ€™ไผš็”จๅˆฐ๏ผ›

ๆ ธๅฟƒไปฃ็ ้›†ไธญๅœจcmdๅ’Œpkgไธญใ€‚่ฟ™ไธคไธชๆ˜ฏ Kubernetes ๆœ€้‡่ฆ็š„ไธคไธชๅŒ…~

cmdๅ†…้ƒจๅŒ…ๅซๅ„ไธช็ป„ไปถ็š„ๅ…ฅๅฃ๏ผŒๅ…ทไฝ“ๆ ธๅฟƒ็š„ๅฎž็Žฐ้ƒจๅˆ†ๅœจpkg็›ฎๅฝ•ไธ‹ใ€‚

ๆˆ‘ไปฌๆฏไธ€ไธช ๅฏๆ‰ง่กŒๆ–‡ไปถ้ƒฝๅฏนๅบ” cmd

ๅ…ณไบŽๅ…ถไป–็›ฎๅฝ•๏ผš

plugin ็›ฎๅฝ•ไน‹ๅ‰็š„็‰ˆๆœฌๅŒ…ๆ‹ฌ scheduler ้ƒจๅˆ†็š„ไปฃ็ ๏ผŒๅฝ“ๅ‰็‰ˆๆœฌ๏ผˆๅบ”่ฏฅๆ˜ฏๅœจ1.10ไน‹ๅŽ๏ผ‰ๅทฒ็ปๅฐ†scheduler้ƒจๅˆ†ไปฃ็ ็งปๅˆฐๅ’Œๅ…ถไป–็ป„ไปถไธ€่‡ด็š„ pkg ็›ฎๅฝ•๏ผŒๆ‰€ไปฅ็›ฎๅ‰ plugin ไธป่ฆๅŒ…ๅซ็š„ๆ˜ฏ่ฎค่ฏไธŽ้‰ดๆƒ้ƒจๅˆ†็š„ไปฃ็ ใ€‚

ๆ น็›ฎๅฝ•

root@cubmaster01:~/go/src/k8s.io/kubernetes# tree -L 1
.
โ”œโ”€โ”€ api
โ”œโ”€โ”€ build
โ”œโ”€โ”€ CHANGELOG
โ”œโ”€โ”€ CHANGELOG.md -> CHANGELOG/README.md
โ”œโ”€โ”€ cluster
โ”œโ”€โ”€ cmd
โ”œโ”€โ”€ code-of-conduct.md
โ”œโ”€โ”€ CONTRIBUTING.md
โ”œโ”€โ”€ docs
โ”œโ”€โ”€ go.mod
โ”œโ”€โ”€ go.sum
โ”œโ”€โ”€ hack
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ LICENSES
โ”œโ”€โ”€ logo
โ”œโ”€โ”€ Makefile -> build/root/Makefile
โ”œโ”€โ”€ Makefile.generated_files -> build/root/Makefile.generated_files
โ”œโ”€โ”€ _output
โ”œโ”€โ”€ OWNERS
โ”œโ”€โ”€ OWNERS_ALIASES
โ”œโ”€โ”€ pkg
โ”œโ”€โ”€ plugin
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ SECURITY_CONTACTS
โ”œโ”€โ”€ staging
โ”œโ”€โ”€ SUPPORT.md
โ”œโ”€โ”€ test
โ”œโ”€โ”€ third_party
โ””โ”€โ”€ vendor

makefile ๆ”ฏๆŒไบคๅ‰็ผ–่ฏ‘็š„๏ผ›

Kubernetes ็š„็ผ–่ฏ‘ๆ–นๆณ•ๆœ‰ไธ‰็ง๏ผŒmakefile ๅ’Œ docker ๆ˜ฏๆ”ฏๆŒไบคๅ‰็ผ–่ฏ‘็š„ใ€‚

api

้กพๅๆ€ไน‰๏ผŒ

โฏ tree api/ -L 2
api/
โ”œโ”€โ”€ api-rules
โ”‚   โ”œโ”€โ”€ aggregator_violation_exceptions.list
โ”‚   โ”œโ”€โ”€ apiextensions_violation_exceptions.list
โ”‚   โ”œโ”€โ”€ codegen_violation_exceptions.list
โ”‚   โ”œโ”€โ”€ README.md
โ”‚   โ”œโ”€โ”€ sample_apiserver_violation_exceptions.list
โ”‚   โ””โ”€โ”€ violation_exceptions.list
โ”œโ”€โ”€ openapi-spec
โ”‚   โ”œโ”€โ”€ README.md
โ”‚   โ”œโ”€โ”€ swagger.json
โ”‚   โ””โ”€โ”€ v3
โ””โ”€โ”€ OWNERS

3 directories, 9 files

ๆˆ‘ไปฌๅฏไปฅ็œ‹ๅˆฐ swagger.json

ๆˆ‘ไปฌ้ƒฝ็Ÿฅ้“ api ๅฃฐๆ˜Ž้ƒฝๆ˜ฏๆœ‰ไธ€ไธช json ๆ–‡ไปถ๏ผŒ้€š่ฟ‡ๅฃฐๆ˜Žๆ‹‰ๅ–ๆ‰€ๆœ‰็š„ API

ๅฆ‚ๆžœๆˆ‘ไปฌ้œ€่ฆ็œ‹ API ๆ–‡ๆกฃ๏ผŒ็œ‹ swagger.json

pkg

::: tip ๅคง้‡็š„ kubernetes ็š„ๆบ็ ๆ‰€ๅœจ๏ผŒ้™คไบ†่ขซๆŠฝ็ฆปไธบๅ•็‹ฌ็ป„ไปถ็š„้ƒจๅˆ†๏ผŒไพ‹ๅฆ‚ api server ็š„ไปฃ็ ๏ผŒproxy ็ป„ไปถ็š„ไปฃ็ ๏ผŒkubelet ็ป„ไปถ็š„ไปฃ็ ใ€‚

  • ไธšๅŠก้€ป่พ‘้ƒฝๅœจ pkg
  • ๅ‘ฝไปค่กŒๅ‚ๆ•ฐ้ƒฝๅœจ cmd

:::

ๅ…ณไบŽไธคไธช็ป„ไปถ๏ผš ./pkg/api ๅ’Œ ./pkg/apis

::: warning Api ๆ–‡ไปถๅคนไธ‹ๅŒ…ๅซๅ’ŒOpen API ็›ธๅ…ณ็š„ๆจกๅž‹ๅฎšไน‰็ญ‰ๅ†…ๅฎนใ€‚

ๅ็งฐไธไธ€ๆ ท๏ผŒไฝœ็”จๆ˜ฏๅฎŒๅ…จไธไธ€ๆ ท็š„ใ€‚

  • ็”จไบŽๆ นๆฎ OpenAPI ่ง„่Œƒๅฝขๆˆ็ฌฆๅˆๅ…ถ่ง„ๅฎš็š„ API

  • apis ๆ˜ฏๅŒ…ๅซๅ†…ๅปบ API Groups ๅ’Œ API Objects ็š„๏ผŒ่€Œ scheme ็›ธๅ…ณ็š„ไปฃ็ ๅคง้ƒจๅˆ†ๅœจ่ฟ™้‡Œใ€‚

:::

root@cubmaster01:~/go/src/k8s.io/kubernetes# tree -L 1 pkg
pkg
โ”œโ”€โ”€ api
โ”œโ”€โ”€ apis
โ”œโ”€โ”€ auth
โ”œโ”€โ”€ capabilities
โ”œโ”€โ”€ client
โ”œโ”€โ”€ cloudprovider
โ”œโ”€โ”€ cluster
โ”œโ”€โ”€ controller
โ”œโ”€โ”€ controlplane
โ”œโ”€โ”€ credentialprovider
โ”œโ”€โ”€ features
โ”œโ”€โ”€ fieldpath
โ”œโ”€โ”€ generated
โ”œโ”€โ”€ kubeapiserver
โ”œโ”€โ”€ kubectl
โ”œโ”€โ”€ kubelet
โ”œโ”€โ”€ kubemark
โ”œโ”€โ”€ OWNERS
โ”œโ”€โ”€ printers
โ”œโ”€โ”€ probe
โ”œโ”€โ”€ proxy
โ”œโ”€โ”€ quota
โ”œโ”€โ”€ registry
โ”œโ”€โ”€ routes
โ”œโ”€โ”€ scheduler
โ”œโ”€โ”€ security
โ”œโ”€โ”€ securitycontext
โ”œโ”€โ”€ serviceaccount
โ”œโ”€โ”€ util
โ”œโ”€โ”€ volume
โ””โ”€โ”€ windows

apis ็›ฎๅฝ•็š„่ฏฆ่งฃ

็›ฎๅฝ•็ป“ๆž„๏ผš

root@cubmaster01:~/go/src/k8s.io/kubernetes/pkg/apis# tree -L 1
.
โ”œโ”€โ”€ abac
โ”œโ”€โ”€ admission
โ”œโ”€โ”€ admissionregistration
โ”œโ”€โ”€ apidiscovery
โ”œโ”€โ”€ apiserverinternal
โ”œโ”€โ”€ apps
โ”œโ”€โ”€ authentication
โ”œโ”€โ”€ authorization
โ”œโ”€โ”€ autoscaling
โ”œโ”€โ”€ batch
โ”œโ”€โ”€ certificates
โ”œโ”€โ”€ coordination
โ”œโ”€โ”€ core
โ”œโ”€โ”€ discovery
โ”œโ”€โ”€ events
โ”œโ”€โ”€ extensions
โ”œโ”€โ”€ flowcontrol
โ”œโ”€โ”€ imagepolicy
โ”œโ”€โ”€ networking
โ”œโ”€โ”€ node
โ”œโ”€โ”€ OWNERS
โ”œโ”€โ”€ policy
โ”œโ”€โ”€ rbac
โ”œโ”€โ”€ resource
โ”œโ”€โ”€ scheduling
โ””โ”€โ”€ storage

ๅœจKubernetesๆบ็ ไธญ๏ผŒcore็›ฎๅฝ•ๅ’Œapps็›ฎๅฝ•ๆ˜ฏไธคไธชไธๅŒ็š„็›ฎๅฝ•๏ผŒ็”จไบŽๅญ˜ๆ”พไธๅŒ็š„APIๅฏน่ฑกใ€‚

  • core็›ฎๅฝ•ไธ‹ๅญ˜ๆ”พ็š„ๆ˜ฏๅŸบ็ก€็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ Podใ€Serviceใ€ReplicationController ็ญ‰ใ€‚่ฟ™ไบ›APIๅฏน่ฑกๆ˜ฏKubernetes็š„ๆ ธๅฟƒๅŠŸ่ƒฝ๏ผŒๆไพ›ไบ†ๅŸบๆœฌ็š„่ฐƒๅบฆใ€็ฎก็†ๅ’Œ็›‘ๆŽงๅŠŸ่ƒฝใ€‚
  • apps็›ฎๅฝ•ไธ‹ๅญ˜ๆ”พ็š„ๆ˜ฏๆ‰ฉๅฑ•็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ Deploymentใ€StatefulSet ็ญ‰ใ€‚่ฟ™ไบ›APIๅฏน่ฑกๆ˜ฏๅฏนๅŸบ็ก€ๅŠŸ่ƒฝ็š„ๆ‰ฉๅฑ•๏ผŒๆไพ›ไบ†ๆ›ดๅคš็š„่ฐƒๅบฆใ€็ฎก็†ๅ’Œ็›‘ๆŽงๅŠŸ่ƒฝใ€‚

ๆ€ปไน‹๏ผŒcore็›ฎๅฝ•ๅ’Œapps็›ฎๅฝ•ๆ˜ฏ็”จๆฅๅญ˜ๆ”พไธๅŒ็ฑปๅž‹็š„APIๅฏน่ฑก็š„ใ€‚ๅฆ‚ๆžœไฝ ๆƒณไบ†่งฃๆŸไธช็‰นๅฎš็š„APIๅฏน่ฑก็š„่ฏฆ็ป†ไฟกๆฏ๏ผŒๅฏไปฅๅœจ็›ธๅบ”็š„็›ฎๅฝ•ไธ‹ๆ‰พๅˆฐๅฏนๅบ”็š„ๆ–‡ไปถใ€‚

ไธป่ฆ็›ฎๅฝ•็š„่งฃ้‡Š๏ผš

pkg/apis็›ฎๅฝ•ๆ˜ฏKubernetesๆบ็ ไธญ็”จไบŽๅญ˜ๆ”พAPIๅฏน่ฑก็š„็›ฎๅฝ•ใ€‚่ฟ™ไธช็›ฎๅฝ•ไธญๅŒ…ๅซไบ†ๅพˆๅคšๅญ็›ฎๅฝ•๏ผŒๆฏไธชๅญ็›ฎๅฝ•ๅญ˜ๆ”พไบ†ไธๅŒ็ฑปๅž‹็š„APIๅฏน่ฑกใ€‚

่ฟ™ไบ›ๅญ็›ฎๅฝ•็š„ๅ็งฐ้€šๅธธ็”ฑไธค้ƒจๅˆ†็ป„ๆˆ๏ผŒไพ‹ๅฆ‚ core/v1ใ€apps/v1 ็ญ‰ใ€‚ๅ‰้ข็š„้ƒจๅˆ†่กจ็คบAPIๅฏน่ฑก็š„็ฑปๅž‹๏ผŒๅŽ้ข็š„้ƒจๅˆ†่กจ็คบAPIๅฏน่ฑก็š„็‰ˆๆœฌใ€‚

ไธ‹้ขๆ˜ฏไธ€ไบ›ๅธธ่ง็š„ๅญ็›ฎๅฝ•ๅŠๅ…ถๅซไน‰๏ผš

  • core/v1๏ผš่ฟ™ไธช็›ฎๅฝ•ไธ‹ๅญ˜ๆ”พ็š„ๆ˜ฏๅŸบ็ก€็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ Podใ€Serviceใ€ReplicationController ็ญ‰ใ€‚่ฟ™ไบ›APIๅฏน่ฑกๆ˜ฏKubernetes็š„ๆ ธๅฟƒๅŠŸ่ƒฝ๏ผŒๆไพ›ไบ†ๅŸบๆœฌ็š„่ฐƒๅบฆใ€็ฎก็†ๅ’Œ็›‘ๆŽงๅŠŸ่ƒฝใ€‚

  • apps/v1๏ผš่ฟ™ไธช็›ฎๅฝ•ไธ‹ๅญ˜ๆ”พ็š„ๆ˜ฏๆ‰ฉๅฑ•็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ Deploymentใ€StatefulSet ็ญ‰

  • batch/v1๏ผš่ฟ™ไธช็›ฎๅฝ•ไธ‹ๅญ˜ๆ”พ็š„ๆ˜ฏๆ‰นๅค„็†็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ Jobใ€CronJob ็ญ‰ใ€‚่ฟ™ไบ›APIๅฏน่ฑกไธป่ฆ็”จไบŽๆ‰ง่กŒๆ‰น้‡ไปปๅŠก๏ผŒๆ”ฏๆŒๅ‘จๆœŸๆ€งๆ‰ง่กŒใ€ๅคฑ่ดฅ้‡่ฏ•็ญ‰ๅŠŸ่ƒฝใ€‚

  • networking.k8s.io/v1๏ผš่ฟ™ไธช็›ฎๅฝ•ไธ‹ๅญ˜ๆ”พ็š„ๆ˜ฏ็ฝ‘็ปœ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ Ingressใ€Service ่ดŸ่ฝฝๅ‡่กกๅ™จ็ญ‰ใ€‚่ฟ™ไบ›APIๅฏน่ฑกไธป่ฆ็”จไบŽๆไพ›้›†็พคๅ†…้ƒจๅŠๅค–้ƒจ็š„็ฝ‘็ปœ่ฎฟ้—ฎ่ƒฝๅŠ›ใ€‚

  • extensions/v1beta1๏ผš่ฟ™ไธช็›ฎๅฝ•ไธ‹ๅญ˜ๆ”พ็š„ๆ˜ฏๆ‰ฉๅฑ•็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ Deploymentใ€Ingress ็ญ‰ใ€‚่ฟ™ไบ›APIๅฏน่ฑกๆ˜ฏๅฏนๅŸบ็ก€ๅŠŸ่ƒฝ็š„ๆ‰ฉๅฑ•๏ผŒๆไพ›ไบ†ๆ›ดๅคš็š„่ฐƒๅบฆใ€็ฎก็†ๅ’Œ็›‘ๆŽงๅŠŸ่ƒฝใ€‚

่ฟ™ไบ›ๅญ็›ฎๅฝ•ๅชๆ˜ฏ้ƒจๅˆ†็›ฎๅฝ•๏ผŒKubernetesไธญ่ฟ˜ๆœ‰่ฎธๅคšๅ…ถไป–ๅญ็›ฎๅฝ•๏ผŒๆฏไธชๅญ็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏไธๅŒ็ฑปๅž‹็š„APIๅฏน่ฑกใ€‚ๅฆ‚ๆžœไฝ ๆƒณไบ†่งฃๆ›ดๅคšไฟกๆฏ๏ผŒๅฏไปฅๅœจKubernetesๆบ็ ไป“ๅบ“ไธญๆŸฅ็œ‹ใ€‚

ๅœจKubernetesๆบ็ ไธญ๏ผŒAPIๅฏน่ฑก็š„ๅฎšไน‰ไธ€่ˆฌ้ƒฝไฝไบŽpkg/apis็›ฎๅฝ•ไธ‹ใ€‚ไพ‹ๅฆ‚๏ผŒDeploymentๅฏน่ฑก็š„ๅฎšไน‰ๅฐฑไฝไบŽpkg/apis/apps/v1/deployment.goๆ–‡ไปถไธญใ€‚

ๅ…ทไฝ“็š„ไฝ็ฝฎๅฏ่ƒฝไผšๆœ‰ๆ‰€ไธๅŒ๏ผŒไฝ†้€šๅธธ้ƒฝๅœจ่ฟ™ไธช็›ฎๅฝ•ๆˆ–ๅ…ถๅญ็›ฎๅฝ•ไธ‹ใ€‚ๅฆ‚ๆžœไฝ ๆƒณๆŸฅ็œ‹ๆŸไธช็‰นๅฎš็š„APIๅฏน่ฑก็š„ๅฎšไน‰๏ผŒไฝ ๅฏไปฅๅœจKubernetesๆบ็ ไป“ๅบ“ไธญๆœ็ดขๅ…ณ้”ฎๅญ—๏ผŒๆ‰พๅˆฐๅฏนๅบ”็š„ๆ–‡ไปถใ€‚

Podๅฏน่ฑก็š„ๅฎšไน‰ไฝไบŽKubernetesๆบ็ ไธญ็š„pkg/apis/core/v1/pod.goๆ–‡ไปถไธญใ€‚

่ฟ™ไธชๆ–‡ไปถไธญๅฎšไน‰ไบ†Podๅฏน่ฑก็š„ๆ‰€ๆœ‰ๅญ—ๆฎต๏ผŒๅŒ…ๆ‹ฌๅ็งฐใ€ๅ‘ฝๅ็ฉบ้—ดใ€็Šถๆ€ใ€ๅฎนๅ™จๅˆ—่กจ็ญ‰ใ€‚ๅฆ‚ๆžœไฝ ๆƒณไบ†่งฃPodๅฏน่ฑก็š„ๆ›ดๅคš็ป†่Š‚๏ผŒๅฏไปฅๅœจ่ฟ™ไธชๆ–‡ไปถไธญๆŸฅ็œ‹ใ€‚

ๅ…ถไป–็›ฎๅฝ•่งฃ้‡Š

pkg/apis็›ฎๅฝ•ไธ‹็š„่ฟ™ไบ›ๅญ็›ฎๅฝ•้ƒฝๆ˜ฏ็”จไบŽๅญ˜ๆ”พไธๅŒ็ฑปๅž‹็š„APIๅฏน่ฑก็š„ใ€‚

  • abac็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏๆŽˆๆƒๅ’Œ่ฎค่ฏ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ AttributePoliciesใ€Policy ็ญ‰ใ€‚
  • admission็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏๅ…ฅ้—จ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ AdmissionConfigurationใ€Webhook ็ญ‰ใ€‚
  • admissionregistration็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏๅ…ฅ้—จๆณจๅ†Œ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ InitializerConfigurationใ€ValidatingWebhookConfiguration ็ญ‰ใ€‚
  • apidiscovery็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏAPIๅ‘็Žฐ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ APIGroupใ€APIResourceList ็ญ‰ใ€‚
  • apiserverinternal็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏAPIๆœๅŠกๅ™จๅ†…้ƒจ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ GroupResourcesใ€ServerResources ็ญ‰ใ€‚
  • authentication็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏ่บซไปฝ้ชŒ่ฏ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ TokenReviewใ€UserInfo ็ญ‰ใ€‚
  • authorization็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏๆŽˆๆƒ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ SelfSubjectAccessReviewใ€SubjectAccessReview ็ญ‰ใ€‚
  • autoscaling็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏ่‡ชๅŠจไผธ็ผฉ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ HorizontalPodAutoscalerใ€Scale ็ญ‰ใ€‚
  • certificates็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏ่ฏไนฆ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ CertificateSigningRequestใ€CertificateSigningRequestList ็ญ‰ใ€‚
  • coordination็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏๅ่ฐƒ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ Leaseใ€Lock ็ญ‰ใ€‚
  • core็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏๅŸบ็ก€็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ Podใ€Serviceใ€ReplicationController
  • discovery็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏๅ‘็Žฐ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ EndpointSliceใ€ServiceAccountToken ็ญ‰ใ€‚
  • events็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏไบ‹ไปถ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ Eventใ€EventList ็ญ‰ใ€‚
  • extensions็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏๆ‰ฉๅฑ•็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ Deploymentใ€Ingress ็ญ‰ใ€‚
  • flowcontrol็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏๆต้‡ๆŽงๅˆถ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ FlowSchemaใ€FlowSchemaList ็ญ‰ใ€‚
  • imagepolicy็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏ้•œๅƒ็ญ–็•ฅ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ ImageReviewใ€ImageReviewStatus ็ญ‰ใ€‚
  • networking็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏ็ฝ‘็ปœ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ Ingressใ€Service ่ดŸ่ฝฝๅ‡่กกๅ™จ็ญ‰ใ€‚
  • node็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏ่Š‚็‚น็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ Nodeใ€NodeList ็ญ‰ใ€‚
  • OWNERS็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏOWNERSๆ–‡ไปถ
  • policy็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏ็ญ–็•ฅ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ PodDisruptionBudgetใ€PodSecurityPolicy ็ญ‰ใ€‚
  • rbac็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏๅŸบไบŽ่ง’่‰ฒ็š„่ฎฟ้—ฎๆŽงๅˆถ๏ผˆRBAC๏ผ‰็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ ClusterRoleใ€RoleBinding ็ญ‰ใ€‚
  • resource็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏ่ต„ๆบ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ ConfigMapใ€PersistentVolume ็ญ‰ใ€‚
  • scheduling็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏ่ฐƒๅบฆ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ PriorityClassใ€Scheduling ็ญ‰ใ€‚
  • storage็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏๅญ˜ๅ‚จ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ StorageClassใ€VolumeAttachment ็ญ‰ใ€‚
  • pkg/apis/apps็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏKubernetes็š„ๆ‰ฉๅฑ•APIๅฏน่ฑกใ€‚่ฟ™ไบ›APIๅฏน่ฑกๆ˜ฏๅฏนๅŸบ็ก€ๅŠŸ่ƒฝ็š„ๆ‰ฉๅฑ•๏ผŒๆไพ›ไบ†ๆ›ดๅคš็š„่ฐƒๅบฆใ€็ฎก็†ๅ’Œ็›‘ๆŽงๅŠŸ่ƒฝใ€‚่ฟ™ไบ›APIๅฏน่ฑกไธป่ฆ็”จไบŽๆ”ฏๆŒๅบ”็”จ็š„้ƒจ็ฝฒใ€ๆ‰ฉๅฑ•ๅ’Œ็ฎก็†ใ€‚

ไพ‹ๅฆ‚๏ผŒpkg/apis/apps/v1็›ฎๅฝ•ไธ‹ๅญ˜ๆ”พ็š„ๆ˜ฏDeploymentใ€StatefulSetใ€DaemonSet็ญ‰APIๅฏน่ฑกใ€‚่ฟ™ไบ›APIๅฏน่ฑกไธป่ฆ็”จไบŽๆ”ฏๆŒๅบ”็”จ็š„้ƒจ็ฝฒใ€ๆ‰ฉๅฑ•ๅ’Œ็ฎก็†ใ€‚

ๅœจpkg/apis/apps็›ฎๅฝ•ไธ‹๏ผŒไฝ ไผšๅ‘็Žฐๆœ‰่ฎธๅคšๅญ็›ฎๅฝ•๏ผŒๆฏไธชๅญ็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏไธๅŒ็‰ˆๆœฌ็š„APIๅฏน่ฑกใ€‚ไพ‹ๅฆ‚๏ผŒpkg/apis/apps/v1็›ฎๅฝ•ไธ‹ๅญ˜ๆ”พ็š„ๆ˜ฏDeploymentใ€StatefulSetใ€DaemonSet็ญ‰APIๅฏน่ฑก็š„v1็‰ˆๆœฌ๏ผŒpkg/apis/apps/v1beta1็›ฎๅฝ•ไธ‹ๅญ˜ๅœจpkg/apis/apps็›ฎๅฝ•ไธ‹๏ผŒไฝ ไผšๅ‘็Žฐๆœ‰่ฎธๅคšๅญ็›ฎๅฝ•๏ผŒๆฏไธชๅญ็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏไธๅŒ็‰ˆๆœฌ็š„APIๅฏน่ฑกใ€‚ไพ‹ๅฆ‚๏ผŒpkg/apis/apps/v1็›ฎๅฝ•ไธ‹ๅญ˜ๆ”พ็š„ๆ˜ฏDeploymentใ€StatefulSetใ€DaemonSet็ญ‰APIๅฏน่ฑก็š„v1็‰ˆๆœฌ๏ผŒpkg/apis/apps/v1beta1็›ฎๅฝ•ไธ‹ๅญ˜ๆ”พ็š„ๆ˜ฏDeploymentใ€StatefulSetใ€DaemonSet็ญ‰APIๅฏน่ฑก็š„v1beta1็‰ˆๆœฌใ€‚

่ฟ™ไบ›ๅญ็›ฎๅฝ•ๆ˜ฏไธบไบ†ๆ”ฏๆŒKubernetes็š„ๅคš็‰ˆๆœฌ็‰นๆ€ง่€Œ่ฎพ่ฎก็š„ใ€‚ๅœจKubernetesไธญ๏ผŒAPIๅฏน่ฑกๅฏไปฅๆœ‰ๅคšไธช็‰ˆๆœฌ๏ผŒ่ฟ™ๆ ทๅฐฑๅฏไปฅๅœจไธ็ ดๅ็Žฐๆœ‰ไปฃ็ ็š„ๆƒ…ๅ†ตไธ‹๏ผŒๆไพ›ๆ–ฐ็š„ๅŠŸ่ƒฝๅ’Œๆ”น่ฟ›ใ€‚่ฟ™ไฝฟๅพ—Kubernetesๆ›ดๅŠ ็ตๆดป๏ผŒไนŸไฝฟๅพ—Kubernetes็š„ๆ›ดๆ–ฐๅ’Œๅ‡็บงๅ˜ๅพ—ๆ›ดๅŠ ๅฎนๆ˜“ใ€‚

ๅœจpkg/apis/apps็›ฎๅฝ•ไธ‹๏ผŒไฝ ่ฟ˜ไผšๅ‘็Žฐๆœ‰ๅพˆๅคšๆ–‡ไปถ๏ผŒ่ฟ™ไบ›ๆ–‡ไปถๆ˜ฏKubernetes็š„ไปฃ็ ็”Ÿๆˆๅ™จไฝฟ็”จ็š„ใ€‚Kubernetes็š„ไปฃ็ ็”Ÿๆˆๅ™จๆ˜ฏไธ€็งๅทฅๅ…ท๏ผŒๅฏไปฅๆ นๆฎ็”จๆˆท็š„่พ“ๅ…ฅ็”ŸๆˆKubernetes็š„APIๅฏน่ฑกไปฃ็ ใ€‚่ฟ™ไฝฟๅพ—Kubernetes็š„APIๅฏน่ฑกๅฏไปฅๆ›ดๅŠ ๅฟซ้€Ÿใ€็ฎ€ๅ•ๅœฐๅผ€ๅ‘๏ผŒไนŸไฝฟๅพ—Kubernetes็š„APIๅฏน่ฑกๅฏไปฅๆ›ดๅŠ ไธ€่‡ดใ€็ปŸไธ€ๅœฐ็ฎก็†ใ€‚

้™คไบ†pkg/apis/apps็›ฎๅฝ•๏ผŒKubernetes่ฟ˜ๆœ‰่ฎธๅคšๅ…ถไป–็›ฎๅฝ•๏ผŒ่ฟ™ไบ›็›ฎๅฝ•ไนŸๆ˜ฏKubernetes็š„ไปฃ็ ็”Ÿๆˆๅ™จไฝฟ็”จ็š„ใ€‚ไพ‹ๅฆ‚๏ผŒpkg/apis/authorization็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏ่ฎค่ฏๅ’ŒๆŽˆๆƒ็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒpkg/apis/batch็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏๆ‰นๅค„็†็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒpkg/apis/coordination็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏๅ่ฐƒ็›ธๅ…ณ็š„APIๅฏน่ฑก็ญ‰ใ€‚


RBAC

::: details about RBAC ๅœจไธŠ้ขๆˆ‘ไปฌ็œ‹ๅˆฐ๏ผŒrbac็›ฎๅฝ•ๅญ˜ๆ”พ็š„ๆ˜ฏๅŸบไบŽ่ง’่‰ฒ็š„่ฎฟ้—ฎๆŽงๅˆถ๏ผˆRBAC๏ผ‰็›ธๅ…ณ็š„APIๅฏน่ฑก๏ผŒไพ‹ๅฆ‚ ClusterRoleใ€RoleBinding ็ญ‰ใ€‚

้‚ฃไนˆ RBAC ๆ˜ฏไป€ไนˆๅ‘ข๏ผŒๅฎƒๆ˜ฏไธ€ๅŸบไบŽ่ง’่‰ฒ็š„ๆƒ้™ๆŽงๅˆถ๏ผŒๆˆ–่ฎธไธ‹้ข็š„ไธ€ๅฅ่ฏ่ƒฝๅธฎๅŠฉไฝ ็†่งฃๅฎƒ๏ผš

ๆˆ‘ไปฌ้ƒฝ็Ÿฅ้“ Kubernetes ไธญๆ‰€ๆœ‰็š„ APIๅฏน่ฑก้ƒฝไฟๅญ˜ๅœจ etcd ไธญ๏ผŒๅฏๆ˜ฏ๏ผŒๅฏนไบŽ่ฟ™ไบ› API ๅฏน่ฑก็š„ๆ“ไฝœไธ€ๅฎšๆ˜ฏ้€š่ฟ‡่ฎฟ้—ฎ kube-apiServer ๅฎž็Žฐ็š„ใ€‚ๅ…ถไธญไธ€ไธช้žๅธธ้‡่ฆ็š„ๅŽŸๅ› ๅฐฑๆ˜ฏ๏ผŒ้œ€่ฆ API Server ๆฅๅธฎๅฟ™ๅทฆๆŽˆๆƒๅทฅไฝœใ€‚่€Œๅœจ Kubernetes ็š„้กน็›ฎไธญ๏ผŒ่ดŸ่ดฃๅฎŒๆˆๆŽˆๆƒๅทฅไฝœ็š„ๆœบๅˆถๆ˜ฏ RBACใ€‚โš ๏ธ

so๏ผŒdirectory structure๏ผš

root@cubmaster01:/workspces/kubernetes/pkg/apis/rbac# ls -al
total 92
drwxr-xr-x  8 root root  4096 Jan  4 06:58 .
drwxr-xr-x 27 root root  4096 Jan  4 06:58 ..
-rw-r--r--  1 root root   698 Nov 30 03:40 doc.go
drwxr-xr-x  2 root root  4096 Nov 30 03:40 fuzzer
-rw-r--r--  1 root root 12362 Nov 30 03:40 helpers.go
-rw-r--r--  1 root root  9453 Nov 30 03:40 helpers_test.go
drwxr-xr-x  2 root root  4096 Nov 30 03:40 install
-rw-r--r--  1 root root   205 Nov 30 03:40 OWNERS
-rw-r--r--  1 root root  1811 Nov 30 03:40 register.go
-rw-r--r--  1 root root  7897 Jan  4 06:58 types.go
drwxr-xr-x  2 root root  4096 Nov 30 03:40 v1
drwxr-xr-x  2 root root  4096 Nov 30 03:40 v1alpha1
drwxr-xr-x  2 root root  4096 Nov 30 03:40 v1beta1
drwxr-xr-x  2 root root  4096 Jan  4 06:58 validation
-rw-r--r--  1 root root 11402 Dec  9 09:16 zz_generated.deepcopy.go

๐Ÿ“œ ๅฏนไธŠ้ข็š„่งฃ้‡Š๏ผš

  • doc.go ๆ–‡ไปถๅŒ…ๅซๅฏนๆ•ดไธชๅŒ…็š„ๆ–‡ๆกฃ็š„ๅผ•็”จใ€‚
  • helpers.go ๆ–‡ไปถๅŒ…ๅซ็”จไบŽๅฎž็Žฐ RBAC ๅŠŸ่ƒฝ็š„ๅธฎๅŠฉ็จ‹ๅบๅ‡ฝๆ•ฐ็š„ไปฃ็ ใ€‚
  • helpers_test.go ๆ–‡ไปถๅŒ…ๅซ็”จไบŽๆต‹่ฏ• helpers.go ไธญ็š„ๅ‡ฝๆ•ฐ็š„ไปฃ็ ใ€‚
  • install ็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽๅฎ‰่ฃ… RBAC API ็š„ไปฃ็ ใ€‚
  • OWNERS ๆ–‡ไปถๅŒ…ๅซๅฏน่ฟ™ไธช็›ฎๅฝ•็š„็ปดๆŠค่€…็š„ๅˆ—่กจใ€‚
  • register.go ๆ–‡ไปถๅŒ…ๅซ็”จไบŽๆณจๅ†Œ RBAC API ็š„ไปฃ็ ใ€‚
  • types.go ๆ–‡ไปถๅŒ…ๅซ็”จไบŽๅฎšไน‰ RBAC API ๅฏน่ฑก็š„ไปฃ็ ใ€‚
  • validation ็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽ้ชŒ่ฏ RBAC API ๅฏน่ฑก็š„ไปฃ็ ใ€‚
  • v1 ็›ฎๅฝ•ๅŒ…ๅซ v1 ็‰ˆๆœฌ็š„ RBAC API ๅฏน่ฑก็š„ๅฎšไน‰ใ€‚
  • v1alpha1 ็›ฎๅฝ•ๅŒ…ๅซ v1alpha1 ็‰ˆๆœฌ็š„ RBAC API ๅฏน่ฑก็š„ๅฎšไน‰ใ€‚
  • v1beta1 ็›ฎๅฝ•ๅŒ…ๅซ v1beta1 ็‰ˆๆœฌ็š„ RBAC API ๅฏน่ฑก็š„ๅฎšไน‰ใ€‚
  • fuzzer ๆ–‡ไปถๅŒ…ๅซ็”จไบŽๆ‰ง่กŒๆจก็ณŠๆต‹่ฏ•็š„ไปฃ็ ใ€‚
  • zz_generated.deepcopy.go ๆ–‡ไปถๅŒ…ๅซ็”จไบŽ็”Ÿๆˆๆทฑๆ‹ท่ดๅ‡ฝๆ•ฐ็š„ไปฃ็ ใ€‚

ๅฏไปฅไฝฟ็”จ types.go ๆ–‡ไปถไธญๅฎšไน‰็š„ Role ๅ’Œ RoleBinding ๅฏน่ฑกๆฅๅˆ›ๅปบๅ’Œ็ฎก็†่ง’่‰ฒใ€‚ๆ‚จๅฏไปฅไฝฟ็”จ register.go ไธญ็š„ไปฃ็ ๆฅๆณจๅ†Œ RBAC API๏ผŒไปŽ่€Œไฝฟๅ…ถๅฏไปฅๅœจ้›†็พคไธญไฝฟ็”จใ€‚ๆ‚จๅฏไปฅไฝฟ็”จ validation ็›ฎๅฝ•ไธญ็š„ไปฃ็ ๆฅ้ชŒ่ฏ RBAC API ๅฏน่ฑก๏ผŒไปฅ็กฎไฟๅฎƒไปฌ็ฌฆๅˆ่ฆๆฑ‚ใ€‚

่ฟ™ไบ›ๆ–‡ไปถๅ’Œ็›ฎๅฝ•ๅ…ฑๅŒๆž„ๆˆไบ† Kubernetes ไธญ็š„ RBAC ๅŠŸ่ƒฝใ€‚RBAC ๅŠŸ่ƒฝไฝฟๆ‚จๅฏไปฅๅœจ้›†็พคไธญๅˆ›ๅปบๅ’Œ็ฎก็†่ง’่‰ฒ๏ผŒๅนถๅฐ†่ง’่‰ฒๅˆ†้…็ป™็”จๆˆทๅ’Œ็ป„๏ผŒไปŽ่€ŒๆŽงๅˆถๅฏน่ต„ๆบ็š„่ฎฟ้—ฎใ€‚

:::

OWENERS ็ปดๆŠค่€…็š„ๅˆ—่กจ

ๅœจ details ๅ†…ๅฎนไธญ๏ผŒๆˆ‘ไปฌ็œ‹ๅˆฐไบ† OWNERS ๆ–‡ไปถ๏ผŒ้’ˆๅฏน Kubernetes ็š„้กน็›ฎๅฏน็ปดๆŠค่€…็š„ๅˆ—่กจๆ–‡ไปถๅšๅ‡บๅˆ†ๆž๏ผŒ่ฟ™ไธชๆ–‡ไปถ๏ผŒไธ็ฎ€ๅ•๏ผ โญ•

# See the OWNERS docs at https://go.k8s.io/owners

# approval on api packages bubbles to api-approvers
reviewers:
  - sig-auth-authorizers-approvers
  - sig-auth-authorizers-reviewers
labels:
  - sig/auth

๐Ÿ“œ ๅฏนไธŠ้ข็š„่งฃ้‡Š๏ผš

OWNERS ๆ–‡ไปถ้€šๅธธๅŒ…ๅซๆœ‰ๅ…ณ็›ฎๅฝ•็š„็ปดๆŠคไบบๅ‘˜็š„ไฟกๆฏใ€‚ๅœจ่ฟ™็งๆƒ…ๅ†ตไธ‹๏ผŒOWNERS ๆ–‡ไปถๅŒ…ๅซๆœ‰ๅ…ณ pkg/apis/rbac ็›ฎๅฝ•็š„็ปดๆŠคไบบๅ‘˜็š„ไฟกๆฏใ€‚

OWNERS ๆ–‡ไปถไธญ็š„ reviewers ๅญ—ๆฎตๅŒ…ๅซไธ€ไธช็”จๆˆทๅๅˆ—่กจ๏ผŒ่กจ็คบๅœจ่ฏฅ็›ฎๅฝ•ไธญๆ‰€ๆœ‰ไปฃ็ ๆ›ดๆ”นๆไบคไน‹ๅ‰ๅฟ…้กปๆไพ›ๆ‰นๅ‡†็š„็”จๆˆทใ€‚่ฟ™ไบ›็”จๆˆท่ขซ็งฐไธบๅฎกๆ ธๅ‘˜ใ€‚ไพ‹ๅฆ‚๏ผŒๅœจๆœฌไพ‹ไธญ๏ผŒๆ‰€ๆœ‰ไปฃ็ ๆ›ดๆ”น้ƒฝๅฟ…้กปๅœจ sig-auth-authorizers-approvers ๅ’Œ sig-auth-authorizers-reviewers ไธคไธช็”จๆˆทไธญ็š„ไธ€ไธชๆ‰นๅ‡†ไน‹ๅŽๆ‰่ƒฝๆไบคใ€‚

OWNERS ๆ–‡ไปถไธญ็š„ labels ๅญ—ๆฎตๅŒ…ๅซไธ€ไธชๆ ‡็ญพๅˆ—่กจ๏ผŒ่กจ็คบไธŽ่ฏฅ็›ฎๅฝ•็›ธๅ…ณ็š„ไธป้ข˜ๆˆ–ๅ…ณๆณจ็‚นใ€‚่ฟ™ไบ›ๆ ‡็ญพๅฏไปฅๅธฎๅŠฉๆ‚จๅฟซ้€Ÿไบ†่งฃ่ฏฅ็›ฎๅฝ•ๆ‰€ๅ…ณๆณจ็š„ๅ†…ๅฎนใ€‚ไพ‹ๅฆ‚๏ผŒๅœจๆœฌไพ‹ไธญ๏ผŒ่ฏฅ็›ฎๅฝ•ไธŽ sig/auth ไธป้ข˜ๆœ‰ๅ…ณใ€‚

OWNERS ๆ–‡ไปถๆ˜ฏ็”จไบŽๆ่ฟฐไธŽ็›ฎๅฝ•็›ธๅ…ณ็š„ไฟกๆฏ็š„ๆ–‡ไปถ๏ผŒไพ‹ๅฆ‚ๅฎกๆ ธๅ‘˜ๅ’Œๅ…ณๆณจ็‚นใ€‚่ฟ™ไบ›ไฟกๆฏๆœ‰ๅŠฉไบŽๅ่ฐƒๅ’Œ็ฎก็†่ฏฅ็›ฎๅฝ•ไธญ็š„ไปฃ็ ใ€‚

โ“ ๆˆ‘ไปฌๆๅˆฐไบ†ไปฃ็ ็”Ÿๆˆๅ™จ๏ผŒๅ…ถๅฎžๅ† ใ€Šๆทฑๅ…ฅ่งฃๆžKubernetes็š„ๆบ็ ใ€‹ ่ฟ™ๆœฌไนฆไธญ๏ผŒๆˆ‘ไปฌไบ†่งฃๅˆฐไบ†ไปฃ็ ็”Ÿๆˆๅ™จ๏ผŒไฝ†ๆ˜ฏไนฆไธญๅ†™็š„้€ป่พ‘ไธๆ˜ฏๅพˆๆธ…ๆ™ฐ๏ผŒๅฏผ่‡ดๅฏน ไปฃ็ ็”Ÿๆˆๅ™จ ็š„็†่งฃไธๆ˜ฏๅพˆ้€ๅฝป~

๐Ÿญ ๆ‰€ไปฅ่ฟ˜ๆ˜ฏๆŽจ่็œ‹ ใ€Šๆทฑๅ…ฅๅ‰–ๆžKubernetesใ€‹

ไปฃ็ ็”Ÿๆˆๅ™จ

Kubernetes็š„ไปฃ็ ็”Ÿๆˆๅ™จๆ˜ฏไธ€็งๅทฅๅ…ท๏ผŒ็”จไบŽ็”ŸๆˆKubernetes็š„APIๅฏน่ฑกไปฃ็ ใ€‚ๅฎƒๅฏไปฅๆ นๆฎ็”จๆˆท็š„่พ“ๅ…ฅ๏ผŒ่‡ชๅŠจ็”ŸๆˆKubernetes APIๅฏน่ฑก็š„ Go ไปฃ็ ใ€‚Kubernetes็š„ไปฃ็ ็”Ÿๆˆๅ™จไฝฟ็”จไบ†ไธ€็งๅซๅš OpenAPI ็š„ๆŠ€ๆœฏ๏ผŒๅฏไปฅ้€š่ฟ‡ๅฎšไน‰ API ๅฏน่ฑก็š„ๆจกๅž‹ๆฅ็”Ÿๆˆไปฃ็ ใ€‚

Kubernetes็š„ไปฃ็ ็”Ÿๆˆๅ™จๆœ‰่ฎธๅคšไผ˜็‚น๏ผŒไพ‹ๅฆ‚๏ผš

  • ๅ‡ๅฐ‘้‡ๅคๅทฅไฝœ๏ผšไฝฟ็”จไปฃ็ ็”Ÿๆˆๅ™จ๏ผŒๅฏไปฅๅ‡ๅฐ‘ๆ‰‹ๅ†™ไปฃ็ ็š„ๅทฅไฝœ้‡ใ€‚
  • ๆ้ซ˜ไปฃ็ ่ดจ้‡๏ผšไฝฟ็”จไปฃ็ ็”Ÿๆˆๅ™จ๏ผŒๅฏไปฅไฟ่ฏ็”Ÿๆˆ็š„ไปฃ็ ่ดจ้‡ๆ›ด้ซ˜๏ผŒๅ› ไธบๅฎƒๆ˜ฏๆ นๆฎๆจกๆฟ็”Ÿๆˆ็š„ใ€‚
  • ไฟ่ฏไปฃ็ ไธ€่‡ดๆ€ง๏ผšไฝฟ็”จไปฃ็ ็”Ÿๆˆๅ™จ๏ผŒๅฏไปฅไฟ่ฏ็”Ÿๆˆ็š„ไปฃ็ ้ฃŽๆ ผไธ€่‡ด๏ผŒๅ› ไธบๅฎƒๆ˜ฏๆ นๆฎๆจกๆฟ็”Ÿๆˆ็š„ใ€‚

Kubernetes็š„ไปฃ็ ็”Ÿๆˆๅ™จๅฏนKubernetes็š„ไฝœ็”จ้žๅธธ้‡่ฆ๏ผŒๅฎƒไฝฟๅพ—Kubernetes็š„APIๅฏน่ฑกๅฏไปฅๆ›ดๅŠ ๅฟซ้€Ÿใ€็ฎ€ๅ•ๅœฐๅผ€ๅ‘๏ผŒไนŸไฝฟๅพ—Kubernetes็š„APIๅฏน่ฑกๅฏไปฅๆ›ดๅŠ ไธ€่‡ดใ€็ปŸไธ€ๅœฐ็ฎก็†ใ€‚

้€š่ฟ‡ไฝฟ็”จไปฃ็ ็”Ÿๆˆๅ™จ๏ผŒKubernetes็š„ๅผ€ๅ‘ไบบๅ‘˜ๅฏไปฅไธ“ๆณจไบŽAPIๅฏน่ฑก็š„ไธšๅŠก้€ป่พ‘๏ผŒ่€Œไธๅฟ…ๆ‹…ๅฟƒๅบ•ๅฑ‚ๅฎž็Žฐ็ป†่Š‚ใ€‚่ฟ™ๅคงๅคง้™ไฝŽไบ†ๅผ€ๅ‘้šพๅบฆ๏ผŒไนŸๆ้ซ˜ไบ†ๅผ€ๅ‘ๆ•ˆ็Ž‡ใ€‚

ๆญคๅค–๏ผŒไฝฟ็”จไปฃ็ ็”Ÿๆˆๅ™จ่ฟ˜ๅฏไปฅไฟ่ฏKubernetes็š„APIๅฏน่ฑกไปฃ็ ่ดจ้‡ๆ›ด้ซ˜๏ผŒๅ› ไธบๅฎƒๆ˜ฏๆ นๆฎๆจกๆฟ็”Ÿๆˆ็š„ใ€‚่ฟ™่ƒฝๅคŸ้ฟๅ…ไบบไธบ็–ๅฟฝๅฏผ่‡ด็š„ไปฃ็ ้”™่ฏฏ๏ผŒไฝฟๅพ—Kubernetes็š„APIๅฏน่ฑกๆ›ดๅŠ ๅฏ้ ใ€‚

ๆ€ป็š„ๆฅ่ฏด๏ผŒKubernetes็š„ไปฃ็ ็”Ÿๆˆๅ™จๆ˜ฏไธ€็ง้žๅธธๆœ‰็”จ็š„ๅทฅๅ…ท๏ผŒๅฎƒไธบKubernetes็š„APIๅฏน่ฑก็š„ๅผ€ๅ‘ๅ’Œ็ฎก็†ๅธฆๆฅไบ†ๅพˆๅคšไพฟๅˆฉใ€‚

Kubernetesๆบ็ ไธญ็š„ไปฃ็ ็”Ÿๆˆๅ™จไพ‹ๅญ๏ผŒไปฅๅŠๅฎƒไปฌๆ‰€ๅœจ็š„ๅœฐๅ€็›ฎๅฝ•๏ผš

  • Deploymentไปฃ็ ็”Ÿๆˆๅ™จ๏ผšpkg/apis/apps/v1/codegen
  • Serviceไปฃ็ ็”Ÿๆˆๅ™จ๏ผšpkg/apis/core/v1/codegen
  • Podไปฃ็ ็”Ÿๆˆๅ™จ๏ผšpkg/apis/core/v1/codegen
  • ReplicationControllerไปฃ็ ็”Ÿๆˆๅ™จ๏ผšpkg/apis/core/v1/codegen
  • Jobไปฃ็ ็”Ÿๆˆๅ™จ๏ผšpkg/apis/batch/v1/codegen
  • CronJobไปฃ็ ็”Ÿๆˆๅ™จ๏ผšpkg/apis/batch/v1beta1/codegen

::: danger ๆ้†’ ๆ›ดๅคšๅ…ณไบŽไปฃ็ ็”Ÿๆˆๅ™จ็š„็Ÿฅ่ฏ†๏ผŒๆŽจ่้˜…่ฏป๏ผš

staging

่ฟ™ไธช็›ฎๅฝ•ๅ‡†็กฎๆฅ่ฏดๆ˜ฏๅญ˜ๆ”พๆ ธๅฟƒ็ป„ไปถ็š„๏ผŒไฝ†ๆ˜ฏๆ˜ฏไธดๆ—ถๅญ˜ๅ‚จ็š„๏ผŒๆˆ‘ไปฌๅฏไปฅๅ‚่€ƒ README.md ๆ–‡ไปถ

ๆญค็›ฎๅฝ•ๆ˜ฏๅทฒๆ‹†ๅˆ†ๅˆฐ่‡ชๅทฑ็š„ๅญ˜ๅ‚จๅบ“็š„ๅŒ…็š„ๆš‚ๅญ˜ๅŒบใ€‚่ฟ™้‡Œ็š„ๅ†…ๅฎนๅฐ†ๅฎšๆœŸๅ‘ๅธƒๅˆฐๅ„่‡ช็š„้กถ็บง k8s.io ๅญ˜ๅ‚จๅบ“ใ€‚

็›ฎๅ‰ๅœจๆญคๅค„ๆš‚ๅญ˜็š„ๅญ˜ๅ‚จๅบ“๏ผš

staging/ ็›ฎๅฝ•ไธญ็š„ไปฃ็ ๆ˜ฏๆƒๅจ็š„๏ผŒๅณไปฃ็ ็š„ๅ”ฏไธ€ๅ‰ฏๆœฌใ€‚ๆ‚จๅฏไปฅ็›ดๆŽฅไฟฎๆ”นๆญค็ฑปไปฃ็ ใ€‚

ไฝฟ็”จ Kubernetes ไปฃ็ ไธญ็š„ๆš‚ๅญ˜ๅญ˜ๅ‚จๅบ“

Kubernetes ไปฃ็ ้€š่ฟ‡็›ฎๅฝ•ไธญ็š„็ฌฆๅท้“พๆŽฅไฝฟ็”จๆญค็›ฎๅฝ•ไธญ็š„ๅญ˜ๅ‚จๅบ“ vendor/k8s.ioๅˆฐๆญคๆš‚ๅญ˜ๅŒบๅŸŸใ€‚ไพ‹ๅฆ‚๏ผŒๅฝ“ Kubernetes ไปฃ็ ไปŽk8s.io/client-goๅญ˜ๅ‚จๅบ“ๅฏผๅ…ฅไธ€ไธชๅŒ…ๆ—ถ๏ผŒ่ฏฅๅฏผๅ…ฅ่ขซ่งฃๆžไธบstaging/src/k8s.io/client-go็›ธๅฏนไบŽ้กน็›ฎๆ น็›ฎๅฝ•๏ผš

// pkg/example/some_code.go
package example

import (
  "k8s.io/client-go/dynamic" // resolves to staging/src/k8s.io/client-go/dynamic
)

ไธ€ๆ—ฆๅฎŒๆˆๅ‘ๅค–้ƒจๅญ˜ๅ‚จๅบ“็š„่ฝฌๆข๏ผŒ่ฟ™ไบ›ๅญ˜ๅ‚จๅบ“ๅฎž้™…ไธŠๅฐ†็”ฑk8s.io/<package-name>.

src/k8s

src/k8s.io/็›ฎๅฝ•ๆ˜ฏKubernetes้กน็›ฎ็š„ๆ น็›ฎๅฝ•๏ผŒๅŒ…ๅซไบ†Kubernetes็ณป็ปŸ็š„ๆ‰€ๆœ‰ๆบไปฃ็ ใ€‚่ฟ™ๆ˜ฏsrc/k8s.io/็›ฎๅฝ•็š„้ซ˜ๅฑ‚็ป“ๆž„๏ผš

root@cubmaster01:/workspces/kubernetes/staging/src/k8s.io# tree -L 1
.
โ”œโ”€โ”€ api
โ”œโ”€โ”€ apiextensions-apiserver
โ”œโ”€โ”€ apimachinery
โ”œโ”€โ”€ apiserver
โ”œโ”€โ”€ client-go
โ”œโ”€โ”€ cli-runtime
โ”œโ”€โ”€ cloud-provider
โ”œโ”€โ”€ cluster-bootstrap
โ”œโ”€โ”€ code-generator
โ”œโ”€โ”€ component-base
โ”œโ”€โ”€ component-helpers
โ”œโ”€โ”€ controller-manager
โ”œโ”€โ”€ cri-api
โ”œโ”€โ”€ csi-translation-lib
โ”œโ”€โ”€ dynamic-resource-allocation
โ”œโ”€โ”€ kms
โ”œโ”€โ”€ kube-aggregator
โ”œโ”€โ”€ kube-controller-manager
โ”œโ”€โ”€ kubectl
โ”œโ”€โ”€ kubelet
โ”œโ”€โ”€ kube-proxy
โ”œโ”€โ”€ kube-scheduler
โ”œโ”€โ”€ legacy-cloud-providers
โ”œโ”€โ”€ metrics
โ”œโ”€โ”€ mount-utils
โ”œโ”€โ”€ noderesourcetopology-api
โ”œโ”€โ”€ pod-security-admission
โ”œโ”€โ”€ sample-apiserver
โ”œโ”€โ”€ sample-cli-plugin
โ””โ”€โ”€ sample-controller

็›ฎๅฝ•ๅŠŸ่ƒฝ๏ผš

  • api/็›ฎๅฝ•ๅŒ…ๅซKubernetes API็š„ๅฎšไน‰ใ€‚
  • apiextensions-apiserver/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽๆ‰ฉๅฑ•Kubernetes API็š„ไปฃ็ ใ€‚
  • apimachinery/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽๆž„ๅปบKubernetes API็š„ๅทฅๅ…ทใ€‚
  • apiserver/็›ฎๅฝ•ๅŒ…ๅซKubernetes APIๆœๅŠกๅ™จ็š„ๆบไปฃ็ ใ€‚
  • client-go/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽ่ฎฟ้—ฎKubernetes API็š„ๅฎขๆˆท็ซฏๅบ“ใ€‚
  • cli-runtime/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽๆ‰ฉๅฑ•kubectl็š„ๅบ“ใ€‚
  • cloud-provider/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽๆ”ฏๆŒไบ‘ๅนณๅฐ็š„ไปฃ็ ใ€‚
  • cluster-bootstrap/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽๅผ•ๅฏผๆ–ฐ้›†็พค็š„ๅทฅๅ…ทใ€‚
  • code-generator/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽ็”ŸๆˆKubernetesไปฃ็ ็š„ๅทฅๅ…ทใ€‚
  • component-base/็›ฎๅฝ•ๅŒ…ๅซKubernetes็ป„ไปถ็š„ๅŸบ็ก€ๅบ“ใ€‚
  • component-helpers/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽๅธฎๅŠฉๆž„ๅปบKubernetes็ป„ไปถ็š„ๅบ“ใ€‚
  • controller-manager/็›ฎๅฝ•ๅŒ…ๅซKubernetesๆŽงๅˆถๅ™จ็ฎก็†ๅ™จ็š„ไปฃ็ ใ€‚
  • csi-translation-lib/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽๅœจKubernetesๅ’Œๅฎนๅ™จๅญ˜ๅ‚จๆŽฅๅฃ(CSI)ไน‹้—ด่ฟ›่กŒ่ฝฌๆข็š„ๅบ“ใ€‚
  • cri-api/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽ่ฟ่กŒๅฎนๅ™จ็š„ไปฃ็ ใ€‚
  • dynamic-resource-allocation/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽๅŠจๆ€ๅˆ†้…่ต„ๆบ็š„ไปฃ็ ใ€‚
  • kms/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽ็ฎก็†ๅŠ ๅฏ†ๅฏ†้’ฅ็š„ไปฃ็ ใ€‚
  • kube-aggregator/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽๆไพ›่šๅˆAPIๆœๅŠกๅ™จ็š„ไปฃ็ ใ€‚
  • kube-controller-manager/็›ฎๅฝ•ๅŒ…ๅซKubernetesๆŽงๅˆถๅ™จ็ฎก็†ๅ™จ็š„ไปฃ็ ใ€‚
  • kubectl/็›ฎๅฝ•ๅŒ…ๅซkubectlๅ‘ฝไปค่กŒๅทฅๅ…ท็š„ๆบไปฃ็ ใ€‚
  • kubelet/็›ฎๅฝ•ๅŒ…ๅซkubelet็š„ๆบไปฃ็ ใ€‚
  • kube-proxy/็›ฎๅฝ•ๅŒ…ๅซKubernetesไปฃ็†็š„ไปฃ็ ใ€‚
  • kube-scheduler/็›ฎๅฝ•ๅŒ…ๅซKubernetes่ฐƒๅบฆ็จ‹ๅบ็š„ไปฃ็ ใ€‚
  • legacy-cloud-providers/็›ฎๅฝ•ๅŒ…ๅซๅทฒๅบŸๅผƒ็š„ไบ‘ๆไพ›ๅ•†ไปฃ็ ใ€‚
  • metrics/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽๆ”ถ้›†Kubernetesๅบฆ้‡ๆŒ‡ๆ ‡็š„ไปฃ็ ใ€‚
  • mount-utils/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽๆŒ‚่ฝฝๆ–‡ไปถ็ณป็ปŸ็š„ๅทฅๅ…ทใ€‚
  • noderesourcetopology-api/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽๆ่ฟฐ่Š‚็‚น่ต„ๆบๆ‹“ๆ‰‘็ป“ๆž„็š„APIใ€‚
  • pod-security-admission/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽๆŽงๅˆถpodๅฎ‰ๅ…จๆ€ง็š„ไปฃ็ ใ€‚
  • sample-apiserver/็›ฎๅฝ•ๅŒ…ๅซKubernetes็คบไพ‹APIๆœๅŠกๅ™จ็š„ไปฃ็ ใ€‚
  • sample-cli-plugin/็›ฎๅฝ•ๅŒ…ๅซ็”จไบŽๆ‰ฉๅฑ•kubectl็š„็คบไพ‹ๆ’ไปถ็š„ไปฃ็ ใ€‚
  • sample-controller/็›ฎๅฝ•ๅŒ…ๅซKubernetes็คบไพ‹ๆŽงๅˆถๅ™จ็š„ไปฃ็ ใ€‚

staging/src/k8s.io/api/

root@cubmaster01:/workspces/kubernetes/staging/src/k8s.io# ls api
admission              authorization       coordination  flowcontrol  node       roundtrip_test.go
admissionregistration  autoscaling         core          go.mod       OWNERS     scheduling
apidiscovery           batch               discovery     go.sum       policy     SECURITY_CONTACTS
apiserverinternal      certificates        doc.go        imagepolicy  rbac       storage
apps                   code-of-conduct.md  events        LICENSE      README.md  testdata
authentication         CONTRIBUTING.md     extensions    networking   resource

ๅŠŸ่ƒฝ๏ผš

  • admission/็›ฎๅฝ•ๅŒ…ๅซไปฃ็ ๏ผŒ็”จไบŽๆŽงๅˆถๅฏน่ต„ๆบ็š„่ฎฟ้—ฎใ€‚
  • admissionregistration/็›ฎๅฝ•ๅŒ…ๅซไปฃ็ ๏ผŒ็”จไบŽๆณจๅ†Œ่ต„ๆบ่ฎฟ้—ฎๆŽงๅˆถ็ป„ไปถใ€‚
  • apidiscovery/็›ฎๅฝ•ๅŒ…ๅซไปฃ็ ๏ผŒ็”จไบŽๆ่ฟฐKubernetes API็š„ๅ‘็Žฐๆœบๅˆถใ€‚
  • apiserverinternal/็›ฎๅฝ•ๅŒ…ๅซไปฃ็ ๏ผŒ็”จไบŽๅฎž็ŽฐKubernetes APIๆœๅŠกๅ™จ็š„ๅ†…้ƒจๅŠŸ่ƒฝใ€‚
  • apps/็›ฎๅฝ•ๅŒ…ๅซไปฃ็ ๏ผŒ็”จไบŽ็ฎก็†ๅบ”็”จ็จ‹ๅบ่ต„ๆบใ€‚
  • authentication/็›ฎๅฝ•ๅŒ…ๅซไปฃ็ ๏ผŒ็”จไบŽๆŽงๅˆถ่บซไปฝ้ชŒ่ฏใ€‚
  • authorization/็›ฎๅฝ•ๅŒ…ๅซไปฃ็ ๏ผŒ็”จไบŽๆŽงๅˆถๆŽˆๆƒใ€‚
  • autoscaling/็›ฎๅฝ•ๅŒ…ๅซไปฃ็ ๏ผŒ็”จไบŽๆŽงๅˆถ่ต„ๆบ็š„่‡ชๅŠจๆ‰ฉๅฑ•ใ€‚
  • batch/็›ฎๅฝ•ๅŒ…ๅซไปฃ็ ๏ผŒ็”จไบŽ็ฎก็†ๆ‰นๅค„็†่ต„ๆบใ€‚
  • certificates/็›ฎๅฝ•ๅŒ…ๅซไปฃ็ ๏ผŒ็”จไบŽ็ฎก็†่ฏไนฆ่ต„ๆบใ€‚
  • coordination/็›ฎๅฝ•ๅŒ…ๅซไปฃ็ ๏ผŒ็”จไบŽ็ฎก็†ๅˆ†ๅธƒๅผๅ่ฐƒ่ต„ๆบใ€‚
  • core/็›ฎๅฝ•ๅŒ…ๅซไปฃ็ ๏ผŒ็”จไบŽ็ฎก็†ๆ ธๅฟƒ่ต„ๆบใ€‚
  • rbac/็›ฎๅฝ•ๅŒ…ๅซไปฃ็ ๏ผŒ็”จไบŽ็ฎก็†่ง’่‰ฒๅŸบๆœฌ่ฎฟ้—ฎๆŽงๅˆถ(RBAC)่ต„ๆบใ€‚
  • scheduling/็›ฎๅฝ•ๅŒ…ๅซไปฃ็ ๏ผŒ็”จไบŽ็ฎก็†่ฐƒๅบฆ่ต„ๆบใ€‚
  • storage/็›ฎๅฝ•ๅŒ…ๅซไปฃ็ ๏ผŒ็”จไบŽ็ฎก็†ๅญ˜ๅ‚จ่ต„ๆบใ€‚

้™คไบ†่ฟ™ไบ›็›ฎๅฝ•ไน‹ๅค–๏ผŒ่ฟ˜ๆœ‰ไธ€ไบ›ๆ–‡ไปถ๏ผŒๅฎƒไปฌไนŸๆ˜ฏ้‡่ฆ็š„้ƒจๅˆ†๏ผš

  • doc.goๆ˜ฏๆ–‡ๆกฃ็š„ๅ…ฅๅฃๆ–‡ไปถใ€‚
  • go.modๅ’Œgo.sumๆ˜ฏGo็š„ไพ่ต–็ฎก็†ๆ–‡ไปถใ€‚
  • LICENSEๆ–‡ไปถๅŒ…ๅซKubernetesไฝฟ็”จ็š„่ฎธๅฏ่ฏใ€‚
  • OWNERSๆ–‡ไปถๅŒ…ๅซ่ดŸ่ดฃ็ปดๆŠค็›ฎๅฝ•็š„ไบบๅ‘˜ๅˆ—่กจใ€‚
  • README.mdๆ–‡ไปถๅŒ…ๅซๆœ‰ๅ…ณ็›ฎๅฝ•็š„ไฟกๆฏใ€‚
  • SECURITY_CONTACTSๆ–‡ไปถๅŒ…ๅซๆœ‰ๅ…ณๅฎ‰ๅ…จ้—ฎ้ข˜็š„่”็ณปไบบๅˆ—่กจใ€‚
  • testdata/็›ฎๅฝ•ๅŒ…ๅซๆต‹่ฏ•ๆ•ฐๆฎใ€‚
  • code-of-conduct.mdๆ–‡ไปถๅŒ…ๅซๆœ‰ๅ…ณKubernetes็คพๅŒบ่กŒไธบๅ‡†ๅˆ™็š„ไฟกๆฏใ€‚
  • CONTRIBUTING.mdๆ–‡ไปถๅŒ…ๅซๆœ‰ๅ…ณๅฆ‚ไฝ•ไธบKubernetes่ดก็Œฎไปฃ็ ็š„ไฟกๆฏใ€‚
  • roundtrip_test.goๆ–‡ไปถๅŒ…ๅซ็”จไบŽๆต‹่ฏ•็š„ไปฃ็ ใ€‚

โš ๏ธ ๐Ÿ“œ ๅฏนไธŠ้ข็š„่งฃ้‡Š๏ผš

ๆˆ‘ไปฌๅฏไปฅ่ฟ›ไธ€ๆญฅๅ†่ง‚ๅฏŸ apps ็›ฎๅฝ•๏ผŒ่ฟ™ไธชๅ็งฐๅพˆ็œผ็†Ÿ๏ผŒpkg/apis/apps/ ็›ฎๅฝ•ๅ’Œ staging/src/k8s.io/api/apps/ ๅฎƒไปฌ็š„็›ฎๅฝ•็ป“ๆž„ๅพˆๆŽฅ่ฟ‘๏ผŒ่ฏท้—ฎๅฎƒไปฌๆœ‰ไป€ไนˆไธไธ€ๆ ท๏ผŒๆˆ‘ๆƒณไบ†่งฃๅฎƒไปฌ็š„ๅฏนๆฏ”่€ŒๅŠ ๆทฑๅฏนๅฎƒไปฌ็š„็†่งฃ

pkg/apis/apps/ ็›ฎๅฝ•ๅ’Œ staging/src/k8s.io/api/apps/็›ฎๅฝ•

pkg/apis/ๅ’Œstaging/src/k8s.io/api/็›ฎๅฝ•้ƒฝๆ˜ฏKubernetesๆบ็ ็š„ไธ€้ƒจๅˆ†ใ€‚ๅฎƒไปฌไน‹้—ด็š„ไธป่ฆๅŒบๅˆซๆ˜ฏ๏ผŒpkg/apis/็›ฎๅฝ•ไธ‹็š„ไปฃ็ ๆ›ดๅŠ ๆŠฝ่ฑก๏ผŒ้€šๅธธๆ˜ฏ็”ฑstaging/src/k8s.io/api/็›ฎๅฝ•ไธ‹็š„ไปฃ็ ๅฎž็Žฐ็š„ใ€‚

ๅœจKubernetesไธญ๏ผŒpkg/apis/็›ฎๅฝ•ไธ‹็š„ไปฃ็ ๅฎšไน‰ไบ†API่ต„ๆบ็š„ๆŠฝ่ฑกๆŽฅๅฃใ€‚่ฟ™ไบ›ๆŽฅๅฃๆ่ฟฐไบ†่ต„ๆบ็š„็ฑปๅž‹ใ€ๅญ—ๆฎตๅ’Œๆ“ไฝœ๏ผŒไฝ†ๆฒกๆœ‰ๅฎž็Žฐๅ…ทไฝ“็š„้€ป่พ‘ใ€‚็›ธๅ๏ผŒstaging/src/k8s.io/api/็›ฎๅฝ•ไธ‹็š„ไปฃ็ ๅฎž็Žฐไบ†่ฟ™ไบ›ๆŽฅๅฃใ€‚่ฟ™ไบ›ๅฎž็Žฐๆไพ›ไบ†่ต„ๆบ็š„ๅ…ทไฝ“ๅŠŸ่ƒฝ๏ผŒๅนถๅฐ†ๅ…ถไธŽKubernetes็ณป็ปŸ็š„ๅ…ถไป–้ƒจๅˆ†้›†ๆˆๅœจไธ€่ตทใ€‚

ไพ‹ๅฆ‚๏ผŒpkg/apis/apps/็›ฎๅฝ•ไธ‹ๅฎšไน‰ไบ†ไธ€็ป„ๆŽฅๅฃ๏ผŒ็”จไบŽ่กจ็คบๅบ”็”จ็จ‹ๅบ่ต„ๆบใ€‚ staging/src/k8s.io/api/apps/็›ฎๅฝ•ไธ‹็š„ไปฃ็ ๅฎž็Žฐไบ†่ฟ™ไบ›ๆŽฅๅฃ๏ผŒๅนถๆไพ›ไบ†ๅบ”็”จ็จ‹ๅบ่ต„ๆบ็š„ๅ…ทไฝ“ๅŠŸ่ƒฝใ€‚

ไธบไบ†่ทŸๆธ…ๆฅš็š„ไบ†่งฃ๏ผŒๆˆ‘ๆˆชๅ–ไบ†ๅฎƒไปฌ็š„็›ฎๅฝ•็ป“ๆž„๏ผš

image-20230107141113159

ๆ€ป็ป“๏ผš

  1. pkg/apis/apps/็›ฎๅฝ•ๅ’Œstaging/src/k8s.io/api/apps/็›ฎๅฝ•้ƒฝๆ˜ฏKubernetesๆบ็ ็š„ไธ€้ƒจๅˆ†ใ€‚ๅฎƒไปฌ้ƒฝๆ˜ฏ็”จไบŽ็ฎก็†ๅบ”็”จ็จ‹ๅบ่ต„ๆบ็š„ไปฃ็ ใ€‚
  2. pkg/apis/apps/็›ฎๅฝ•ไธญ็š„ไปฃ็ ๅฎšไน‰ไบ†ๆŠฝ่ฑก็š„APIๆŽฅๅฃ๏ผŒ็”จไบŽๆ่ฟฐๅบ”็”จ็จ‹ๅบ่ต„ๆบ็š„็ฑปๅž‹ใ€ๅญ—ๆฎตๅ’Œๆ“ไฝœใ€‚ๅฎƒๅนถๆฒกๆœ‰ๆไพ›่ต„ๆบ็š„ๅ…ทไฝ“ๅŠŸ่ƒฝใ€‚
  3. staging/src/k8s.io/api/apps/็›ฎๅฝ•ไธญ็š„ไปฃ็ ๅฎž็Žฐไบ†pkg/apis/apps/็›ฎๅฝ•ไธญ็š„ๆŽฅๅฃใ€‚ๅฎƒๆไพ›ไบ†ๅบ”็”จ็จ‹ๅบ่ต„ๆบ็š„ๅ…ทไฝ“ๅŠŸ่ƒฝ๏ผŒๅนถๅฐ†ๅ…ถไธŽKubernetes็ณป็ปŸ็š„ๅ…ถไป–้ƒจๅˆ†้›†ๆˆๅœจไธ€่ตทใ€‚
  4. ๆ€ป็š„ๆฅ่ฏด๏ผŒpkg/apis/็›ฎๅฝ•ไธญ็š„ไปฃ็ ๆ˜ฏKubernetesไธญAPI่ต„ๆบ็š„ๆŠฝ่ฑกๆŽฅๅฃ๏ผŒ่€Œstaging/src/k8s.io/api/็›ฎๅฝ•ไธญ็š„ไปฃ็ ๅˆ™ๆ˜ฏ่ฟ™ไบ›ๆŽฅๅฃ็š„ๅ…ทไฝ“ๅฎž็Žฐใ€‚

cmd

cmd ็ฎ—ๆ˜ฏ ๅ…ฅๅฃ๏ผŒไนŸๆ˜ฏๅ‘ฝไปค่กŒ็š„ๅฎšไน‰ๅœฐๆ–นใ€‚

root@cubmaster01:~/go/src/k8s.io/kubernetes# tree -L 1 cmd
cmd
โ”œโ”€โ”€ clicheck
โ”œโ”€โ”€ cloud-controller-manager
โ”œโ”€โ”€ dependencycheck
โ”œโ”€โ”€ dependencyverifier
โ”œโ”€โ”€ gendocs
โ”œโ”€โ”€ genkubedocs
โ”œโ”€โ”€ genman
โ”œโ”€โ”€ genswaggertypedocs
โ”œโ”€โ”€ genutils
โ”œโ”€โ”€ genyaml
โ”œโ”€โ”€ importverifier
โ”œโ”€โ”€ kubeadm
โ”œโ”€โ”€ kube-apiserver
โ”œโ”€โ”€ kube-controller-manager
โ”œโ”€โ”€ kubectl
โ”œโ”€โ”€ kubectl-convert
โ”œโ”€โ”€ kubelet
โ”œโ”€โ”€ kubemark
โ”œโ”€โ”€ kube-proxy
โ”œโ”€โ”€ kube-scheduler
โ”œโ”€โ”€ linkcheck
โ”œโ”€โ”€ OWNERS
โ”œโ”€โ”€ preferredimports
โ”œโ”€โ”€ prune-junit-xml
โ””โ”€โ”€ yamlfmt

::: tip kube-apiserver ไธญๆœ‰ apiserver.go ๆ–‡ไปถ๏ผŒๅฐฑๆ˜ฏ apiserver ๅฏๅŠจๅ…ฅๅฃ

:::

cmd ๆœ‰ๅพˆๅคš็š„ๅญ็›ฎๅฝ•๏ผŒไธๅŒ็š„ๅญ็›ฎๅฝ•้ƒฝๅฏนๅบ”็š„ๆŽฅๅฃ๏ผŒๆฏ”ๅฆ‚ไธŠ้ข็š„ API Server

ๆˆ‘ไปฌ็”š่‡ณๅฏไปฅ็›ดๆŽฅๅœจ้‡Œ้ข go build ๏ผš

โฏ cd cmd/kube-apiserver;ls
apiserver.go  app  OWNERS
โฏ go build apiserver.go

ไธ่ฟ‡ไธ€่ˆฌไฝฟ็”จ ๅŠŸ่ƒฝๅผบๅคง ็š„ Makefile ๏ผŒ่€Œไธ”Makefileๆ”ฏๆŒไบคๅ‰็ผ–่ฏ‘ใ€‚

Kubernetes ๆ˜ฏๅพˆๅคš็ป„ไปถ็š„ ไบŒ่ฟ›ๅˆถ ็›ธไบ’้…ๅˆ ้ƒจ็ฝฒ่ตทๆฅ็š„ใ€‚

kube-apiserver

ไปฅ kube-apiserver cmd ็›ฎๅฝ•ไธบไพ‹๏ผš

image-20230303135004177

๐Ÿ“œ ๅฏนไธŠ้ข็š„่งฃ้‡Š๏ผš

  • options ๏ผš ไธ€่ˆฌ้‡Œ้ข็š„ options ๆ˜ฏ่งฃๆž ๅ…ฅๅ‚๏ผŒๅนถไธ”่ฟ›่กŒๅ…ฅๅ‚ๆ ก้ชŒ
  • ้‡Œ้ข็š„ๆ ธๅฟƒ้ƒฝๆ˜ฏ่ฐƒๅˆฐ pkg/* ไธ‹้ข็š„๏ผŒๆฏ”ๅฆ‚่ฏด apiใ€apisๅฏน่ฑก

build

root@cubmaster01:~/go/src/k8s.io/kubernetes# tree -L 1 build
build
โ”œโ”€โ”€ build-image
โ”œโ”€โ”€ common.sh
โ”œโ”€โ”€ copy-output.sh
โ”œโ”€โ”€ dependencies.yaml
โ”œโ”€โ”€ lib
โ”œโ”€โ”€ make-build-image.sh
โ”œโ”€โ”€ make-clean.sh
โ”œโ”€โ”€ nsswitch.conf
โ”œโ”€โ”€ OWNERS
โ”œโ”€โ”€ package-tarballs.sh
โ”œโ”€โ”€ pause
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ release-images.sh
โ”œโ”€โ”€ release-in-a-container.sh
โ”œโ”€โ”€ release.sh
โ”œโ”€โ”€ root
โ”œโ”€โ”€ run.sh
โ”œโ”€โ”€ server-image
โ”œโ”€โ”€ shell.sh
โ”œโ”€โ”€ tools.go
โ””โ”€โ”€ util.sh

vendor

root@cubmaster01:~/go/src/k8s.io/kubernetes# tree -L 1 vendor/
vendor/
โ”œโ”€โ”€ bitbucket.org
โ”œโ”€โ”€ cloud.google.com
โ”œโ”€โ”€ github.com
โ”œโ”€โ”€ go.etcd.io
โ”œโ”€โ”€ golang.org
โ”œโ”€โ”€ gonum.org
โ”œโ”€โ”€ google.golang.org
โ”œโ”€โ”€ go.opencensus.io
โ”œโ”€โ”€ go.opentelemetry.io
โ”œโ”€โ”€ gopkg.in
โ”œโ”€โ”€ go.starlark.net
โ”œโ”€โ”€ go.uber.org
โ”œโ”€โ”€ k8s.io
โ”œโ”€โ”€ modules.txt
โ”œโ”€โ”€ OWNERS
โ””โ”€โ”€ sigs.k8s.io

hack

root@cubmaster01:~/go/src/k8s.io/kubernetes# tree -L 1 hack/
hack/
โ”œโ”€โ”€ benchmark-go.sh
โ”œโ”€โ”€ boilerplate
โ”œโ”€โ”€ build-cross.sh
โ”œโ”€โ”€ build-go.sh
โ”œโ”€โ”€ cherry_pick_pull.sh
โ”œโ”€โ”€ conformance
โ”œโ”€โ”€ dev-build-and-push.sh
โ”œโ”€โ”€ dev-build-and-up.sh
โ”œโ”€โ”€ dev-push-conformance.sh
โ”œโ”€โ”€ e2e-internal
โ”œโ”€โ”€ e2e-node-test.sh
โ”œโ”€โ”€ generate-docs.sh
โ”œโ”€โ”€ gen-swagger-doc
โ”œโ”€โ”€ get-build.sh
โ”œโ”€โ”€ ginkgo-e2e.sh
โ”œโ”€โ”€ grab-profiles.sh
โ”œโ”€โ”€ install-etcd.sh
โ”œโ”€โ”€ jenkins
โ”œโ”€โ”€ lib
โ”œโ”€โ”€ lint-dependencies.sh
โ”œโ”€โ”€ list-feature-tests.sh
โ”œโ”€โ”€ local-up-cluster.sh
โ”œโ”€โ”€ logcheck.conf
โ”œโ”€โ”€ make-rules
โ”œโ”€โ”€ module-graph.sh
โ”œโ”€โ”€ OWNERS
โ”œโ”€โ”€ pin-dependency.sh
โ”œโ”€โ”€ print-workspace-status.sh
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ run-in-gopath.sh
โ”œโ”€โ”€ run-prometheus-on-etcd-scrapes.sh
โ”œโ”€โ”€ serve-prom-scrapes.sh
โ”œโ”€โ”€ testdata
โ”œโ”€โ”€ test-go.sh
โ”œโ”€โ”€ test-integration.sh
โ”œโ”€โ”€ tools
โ”œโ”€โ”€ unwanted-dependencies.json
โ”œโ”€โ”€ update-all.sh
โ”œโ”€โ”€ update-codegen.sh
โ”œโ”€โ”€ update-conformance-yaml.sh
โ”œโ”€โ”€ update-generated-api-compatibility-data.sh
โ”œโ”€โ”€ update-generated-device-plugin-dockerized.sh
โ”œโ”€โ”€ update-generated-device-plugin.sh
โ”œโ”€โ”€ update-generated-docs.sh
โ”œโ”€โ”€ update-generated-kms-dockerized.sh
โ”œโ”€โ”€ update-generated-kms.sh
โ”œโ”€โ”€ update-generated-kubelet-plugin-registration-dockerized.sh
โ”œโ”€โ”€ update-generated-kubelet-plugin-registration.sh
โ”œโ”€โ”€ update-generated-pod-resources-dockerized.sh
โ”œโ”€โ”€ update-generated-pod-resources.sh
โ”œโ”€โ”€ update-generated-protobuf-dockerized.sh
โ”œโ”€โ”€ update-generated-protobuf.sh
โ”œโ”€โ”€ update-generated-runtime-dockerized.sh
โ”œโ”€โ”€ update-generated-runtime.sh
โ”œโ”€โ”€ update-generated-stable-metrics.sh
โ”œโ”€โ”€ update-generated-swagger-docs.sh
โ”œโ”€โ”€ update-gofmt.sh
โ”œโ”€โ”€ update-import-aliases.sh
โ”œโ”€โ”€ update-internal-modules.sh
โ”œโ”€โ”€ update-kustomize.sh
โ”œโ”€โ”€ update-mocks.sh
โ”œโ”€โ”€ update-netparse-cve.sh
โ”œโ”€โ”€ update-openapi-spec.sh
โ”œโ”€โ”€ update-translations.sh
โ”œโ”€โ”€ update-vendor-licenses.sh
โ”œโ”€โ”€ update-vendor.sh
โ”œโ”€โ”€ update-yamlfmt.sh
โ”œโ”€โ”€ verify-all.sh
โ”œโ”€โ”€ verify-api-groups.sh
โ”œโ”€โ”€ verify-boilerplate.sh
โ”œโ”€โ”€ verify-cli-conventions.sh
โ”œโ”€โ”€ verify-codegen.sh
โ”œโ”€โ”€ verify-conformance-requirements.sh
โ”œโ”€โ”€ verify-conformance-yaml.sh
โ”œโ”€โ”€ verify-description.sh
โ”œโ”€โ”€ verify-e2e-test-ownership.sh
โ”œโ”€โ”€ verify-external-dependencies-version.sh
โ”œโ”€โ”€ verify-flags
โ”œโ”€โ”€ verify-flags-underscore.py
โ”œโ”€โ”€ verify-generated-device-plugin.sh
โ”œโ”€โ”€ verify-generated-docs.sh
โ”œโ”€โ”€ verify-generated-files-remake.sh
โ”œโ”€โ”€ verify-generated-files.sh
โ”œโ”€โ”€ verify-generated-kms.sh
โ”œโ”€โ”€ verify-generated-kubelet-plugin-registration.sh
โ”œโ”€โ”€ verify-generated-pod-resources.sh
โ”œโ”€โ”€ verify-generated-protobuf.sh
โ”œโ”€โ”€ verify-generated-runtime.sh
โ”œโ”€โ”€ verify-generated-stable-metrics.sh
โ”œโ”€โ”€ verify-generated-swagger-docs.sh
โ”œโ”€โ”€ verify-gofmt.sh
โ”œโ”€โ”€ verify-golangci-lint.sh
โ”œโ”€โ”€ verify-govet-levee.sh
โ”œโ”€โ”€ verify-govet.sh
โ”œโ”€โ”€ verify-import-aliases.sh
โ”œโ”€โ”€ verify-import-boss.sh
โ”œโ”€โ”€ verify-imports.sh
โ”œโ”€โ”€ verify-internal-modules.sh
โ”œโ”€โ”€ verify-linkcheck.sh
โ”œโ”€โ”€ verify-mocks.sh
โ”œโ”€โ”€ verify-netparse-cve.sh
โ”œโ”€โ”€ verify-non-mutating-validation.sh
โ”œโ”€โ”€ verify-no-vendor-cycles.sh
โ”œโ”€โ”€ verify-openapi-spec.sh
โ”œโ”€โ”€ verify-pkg-names.sh
โ”œโ”€โ”€ verify-prerelease-lifecycle-tags.sh
โ”œโ”€โ”€ verify-prometheus-imports.sh
โ”œโ”€โ”€ verify-publishing-bot.py
โ”œโ”€โ”€ verify-readonly-packages.sh
โ”œโ”€โ”€ verify-shellcheck.sh
โ”œโ”€โ”€ verify-spelling.sh
โ”œโ”€โ”€ verify-staging-meta-files.sh
โ”œโ”€โ”€ verify-test-code.sh
โ”œโ”€โ”€ verify-test-featuregates.sh
โ”œโ”€โ”€ verify-test-images.sh
โ”œโ”€โ”€ verify-typecheck-providerless.sh
โ”œโ”€โ”€ verify-typecheck.sh
โ”œโ”€โ”€ verify-vendor-licenses.sh
โ”œโ”€โ”€ verify-vendor.sh
โ””โ”€โ”€ verify-yamlfmt.sh

plugin

plugin็›ฎๅฝ•ไน‹ๅ‰็š„็‰ˆๆœฌๅŒ…ๆ‹ฌ scheduler ้ƒจๅˆ†็š„ไปฃ็ ๏ผŒๅฝ“ๅ‰็‰ˆๆœฌ๏ผˆๅบ”่ฏฅๆ˜ฏๅœจ1.10ไน‹ๅŽ๏ผ‰ๅทฒ็ปๅฐ†scheduler้ƒจๅˆ†ไปฃ็ ็งปๅˆฐๅ’Œๅ…ถไป–็ป„ไปถไธ€่‡ด็š„pkg็›ฎๅฝ•๏ผŒๆ‰€ไปฅ็›ฎๅ‰ plugin ไธป่ฆๅŒ…ๅซ็š„ๆ˜ฏ่ฎค่ฏไธŽ้‰ดๆƒ้ƒจๅˆ†็š„ไปฃ็ ใ€‚

root@cubmaster01:~/go/src/k8s.io/kubernetes# tree plugin/ -L 4
plugin/
โ”œโ”€โ”€ OWNERS
โ””โ”€โ”€ pkg
    โ”œโ”€โ”€ admission
    โ”‚   โ”œโ”€โ”€ admit
    โ”‚   โ”‚   โ”œโ”€โ”€ admission.go
    โ”‚   โ”‚   โ””โ”€โ”€ admission_test.go
    โ”‚   โ”œโ”€โ”€ alwayspullimages
    โ”‚   โ”‚   โ”œโ”€โ”€ admission.go
    โ”‚   โ”‚   โ””โ”€โ”€ admission_test.go
    โ”‚   โ”œโ”€โ”€ antiaffinity
    โ”‚   โ”‚   โ”œโ”€โ”€ admission.go
    โ”‚   โ”‚   โ”œโ”€โ”€ admission_test.go
    โ”‚   โ”‚   โ””โ”€โ”€ doc.go
    โ”‚   โ”œโ”€โ”€ certificates
    โ”‚   โ”‚   โ”œโ”€โ”€ approval
    โ”‚   โ”‚   โ”œโ”€โ”€ OWNERS
    โ”‚   โ”‚   โ”œโ”€โ”€ signing
    โ”‚   โ”‚   โ”œโ”€โ”€ subjectrestriction
    โ”‚   โ”‚   โ””โ”€โ”€ util.go
    โ”‚   โ”œโ”€โ”€ defaulttolerationseconds
    โ”‚   โ”‚   โ”œโ”€โ”€ admission.go
    โ”‚   โ”‚   โ””โ”€โ”€ admission_test.go
    โ”‚   โ”œโ”€โ”€ deny
    โ”‚   โ”‚   โ”œโ”€โ”€ admission.go
    โ”‚   โ”‚   โ””โ”€โ”€ admission_test.go
    โ”‚   โ”œโ”€โ”€ eventratelimit
    โ”‚   โ”‚   โ”œโ”€โ”€ admission.go
    โ”‚   โ”‚   โ”œโ”€โ”€ admission_test.go
    โ”‚   โ”‚   โ”œโ”€โ”€ apis
    โ”‚   โ”‚   โ”œโ”€โ”€ cache.go
    โ”‚   โ”‚   โ”œโ”€โ”€ cache_test.go
    โ”‚   โ”‚   โ”œโ”€โ”€ config.go
    โ”‚   โ”‚   โ”œโ”€โ”€ doc.go
    โ”‚   โ”‚   โ””โ”€โ”€ limitenforcer.go
    โ”‚   โ”œโ”€โ”€ extendedresourcetoleration
    โ”‚   โ”‚   โ”œโ”€โ”€ admission.go
    โ”‚   โ”‚   โ””โ”€โ”€ admission_test.go
    โ”‚   โ”œโ”€โ”€ gc
    โ”‚   โ”‚   โ”œโ”€โ”€ gc_admission.go
    โ”‚   โ”‚   โ””โ”€โ”€ gc_admission_test.go
    โ”‚   โ”œโ”€โ”€ imagepolicy
    โ”‚   โ”‚   โ”œโ”€โ”€ admission.go
    โ”‚   โ”‚   โ”œโ”€โ”€ admission_test.go
    โ”‚   โ”‚   โ”œโ”€โ”€ certs_test.go
    โ”‚   โ”‚   โ”œโ”€โ”€ config.go
    โ”‚   โ”‚   โ”œโ”€โ”€ config_test.go
    โ”‚   โ”‚   โ”œโ”€โ”€ doc.go
    โ”‚   โ”‚   โ”œโ”€โ”€ gencerts.sh
    โ”‚   โ”‚   โ””โ”€โ”€ OWNERS
    โ”‚   โ”œโ”€โ”€ limitranger
    โ”‚   โ”‚   โ”œโ”€โ”€ admission.go
    โ”‚   โ”‚   โ”œโ”€โ”€ admission_test.go
    โ”‚   โ”‚   โ””โ”€โ”€ interfaces.go
    โ”‚   โ”œโ”€โ”€ namespace
    โ”‚   โ”‚   โ”œโ”€โ”€ autoprovision
    โ”‚   โ”‚   โ””โ”€โ”€ exists
    โ”‚   โ”œโ”€โ”€ network
    โ”‚   โ”‚   โ”œโ”€โ”€ defaultingressclass
    โ”‚   โ”‚   โ””โ”€โ”€ denyserviceexternalips
    โ”‚   โ”œโ”€โ”€ noderestriction
    โ”‚   โ”‚   โ”œโ”€โ”€ admission.go
    โ”‚   โ”‚   โ”œโ”€โ”€ admission_test.go
    โ”‚   โ”‚   โ””โ”€โ”€ OWNERS
    โ”‚   โ”œโ”€โ”€ nodetaint
    โ”‚   โ”‚   โ”œโ”€โ”€ admission.go
    โ”‚   โ”‚   โ””โ”€โ”€ admission_test.go
    โ”‚   โ”œโ”€โ”€ OWNERS
    โ”‚   โ”œโ”€โ”€ podnodeselector
    โ”‚   โ”‚   โ”œโ”€โ”€ admission.go
    โ”‚   โ”‚   โ””โ”€โ”€ admission_test.go
    โ”‚   โ”œโ”€โ”€ podtolerationrestriction
    โ”‚   โ”‚   โ”œโ”€โ”€ admission.go
    โ”‚   โ”‚   โ”œโ”€โ”€ admission_test.go
    โ”‚   โ”‚   โ”œโ”€โ”€ apis
    โ”‚   โ”‚   โ”œโ”€โ”€ config.go
    โ”‚   โ”‚   โ””โ”€โ”€ doc.go
    โ”‚   โ”œโ”€โ”€ priority
    โ”‚   โ”‚   โ”œโ”€โ”€ admission.go
    โ”‚   โ”‚   โ””โ”€โ”€ admission_test.go
    โ”‚   โ”œโ”€โ”€ resourcequota
    โ”‚   โ”‚   โ””โ”€โ”€ admission_test.go
    โ”‚   โ”œโ”€โ”€ runtimeclass
    โ”‚   โ”‚   โ”œโ”€โ”€ admission.go
    โ”‚   โ”‚   โ”œโ”€โ”€ admission_test.go
    โ”‚   โ”‚   โ””โ”€โ”€ OWNERS
    โ”‚   โ”œโ”€โ”€ security
    โ”‚   โ”‚   โ”œโ”€โ”€ doc.go
    โ”‚   โ”‚   โ”œโ”€โ”€ podsecurity
    โ”‚   โ”‚   โ””โ”€โ”€ podsecuritypolicy
    โ”‚   โ”œโ”€โ”€ securitycontext
    โ”‚   โ”‚   โ””โ”€โ”€ scdeny
    โ”‚   โ”œโ”€โ”€ serviceaccount
    โ”‚   โ”‚   โ”œโ”€โ”€ admission.go
    โ”‚   โ”‚   โ”œโ”€โ”€ admission_test.go
    โ”‚   โ”‚   โ”œโ”€โ”€ doc.go
    โ”‚   โ”‚   โ””โ”€โ”€ OWNERS
    โ”‚   โ””โ”€โ”€ storage
    โ”‚       โ”œโ”€โ”€ persistentvolume
    โ”‚       โ”œโ”€โ”€ storageclass
    โ”‚       โ””โ”€โ”€ storageobjectinuseprotection
    โ””โ”€โ”€ auth
        โ”œโ”€โ”€ authenticator
        โ”‚   โ”œโ”€โ”€ OWNERS
        โ”‚   โ””โ”€โ”€ token
        โ”œโ”€โ”€ authorizer
        โ”‚   โ”œโ”€โ”€ doc.go
        โ”‚   โ”œโ”€โ”€ node
        โ”‚   โ”œโ”€โ”€ OWNERS
        โ”‚   โ””โ”€โ”€ rbac
        โ”œโ”€โ”€ doc.go
        โ””โ”€โ”€ OWNERS

test

e2e ๆต‹่ฏ•ไปฃ็ 

Kubernetes ็š„ ETC ็›ฎๅฝ•

Kubernetes ๆ˜ฏไธ€ไธชๅนฟๆณ›ไฝฟ็”จ็š„ๅฎนๅ™จ็ผ–ๆŽ’ๅนณๅฐ๏ผŒไธ‹้ขๆ˜ฏ Kubernetes ็š„็›ฎๅฝ•ๅ’Œๆ–‡ไปถ๏ผŒๅŒ…ๆ‹ฌไบ†ๅนณๅฐ็š„ๆ ธๅฟƒ็ป„ไปถๅ’Œ่ฏไนฆ็ญ‰็›ธๅ…ณๆ–‡ไปถใ€‚

โ”œโ”€โ”€ audit-policy.yml
โ”œโ”€โ”€ controller-manager.conf
โ”œโ”€โ”€ kubeadm.yaml
โ”œโ”€โ”€ kubelet.conf
โ”œโ”€โ”€ manifests
โ”‚   โ”œโ”€โ”€ etcd.yaml
โ”‚   โ”œโ”€โ”€ kube-apiserver.yaml
โ”‚   โ”œโ”€โ”€ kube-controller-manager.yaml
โ”‚   โ””โ”€โ”€ kube-scheduler.yaml
โ”œโ”€โ”€ pki
โ”‚   โ”œโ”€โ”€ apiserver.crt
โ”‚   โ”œโ”€โ”€ apiserver-etcd-client.crt
โ”‚   โ”œโ”€โ”€ apiserver-etcd-client.key
โ”‚   โ”œโ”€โ”€ apiserver.key
โ”‚   โ”œโ”€โ”€ apiserver-kubelet-client.crt
โ”‚   โ”œโ”€โ”€ apiserver-kubelet-client.key
โ”‚   โ”œโ”€โ”€ ca.crt
โ”‚   โ”œโ”€โ”€ ca.key
โ”‚   โ”œโ”€โ”€ etcd
โ”‚   โ”‚   โ”œโ”€โ”€ ca.crt
โ”‚   โ”‚   โ”œโ”€โ”€ ca.key
โ”‚   โ”‚   โ”œโ”€โ”€ healthcheck-client.crt
โ”‚   โ”‚   โ”œโ”€โ”€ healthcheck-client.key
โ”‚   โ”‚   โ”œโ”€โ”€ peer.crt
โ”‚   โ”‚   โ”œโ”€โ”€ peer.key
โ”‚   โ”‚   โ”œโ”€โ”€ server.crt
โ”‚   โ”‚   โ””โ”€โ”€ server.key
โ”‚   โ”œโ”€โ”€ front-proxy-ca.crt
โ”‚   โ”œโ”€โ”€ front-proxy-ca.key
โ”‚   โ”œโ”€โ”€ front-proxy-client.crt
โ”‚   โ”œโ”€โ”€ front-proxy-client.key
โ”‚   โ”œโ”€โ”€ sa.key
โ”‚   โ””โ”€โ”€ sa.pub
โ””โ”€โ”€ scheduler.conf

audit-policy.yml

audit-policy.yml ๆ˜ฏ Kubernetes ็š„ๅฎกๆ ธ็ญ–็•ฅๆ–‡ไปถ๏ผŒๅฎƒ่ง„ๅฎšไบ†ๅ“ชไบ›ไบ‹ไปถ้œ€่ฆ่ขซ่ฎฐๅฝ•๏ผŒไปฅๅŠ่ฎฐๅฝ•็š„ๅ†…ๅฎนใ€‚

controller-manager.conf

controller-manager.conf ๆ˜ฏ Kubernetes ็š„ๆŽงๅˆถๅ™จ็ฎก็†ๅ™จ็š„้…็ฝฎๆ–‡ไปถใ€‚

kubeadm.yaml

kubeadm.yaml ๆ˜ฏ Kubernetes ็š„ๅˆๅง‹ๅŒ–้…็ฝฎๆ–‡ไปถ๏ผŒๅŒ…ๅซไบ†ๅˆๅง‹ๅŒ–้›†็พคๆ‰€้œ€่ฆ็š„ไฟกๆฏใ€‚

kubelet.conf

kubelet.conf ๆ˜ฏ Kubernetes ็š„ kubelet ็ป„ไปถ็š„้…็ฝฎๆ–‡ไปถใ€‚

manifests

manifests ็›ฎๅฝ•ๅŒ…ๅซ Kubernetes ็š„ๆ ธๅฟƒ็ป„ไปถ็š„้…็ฝฎๆ–‡ไปถ๏ผŒๅฎƒไปฌๆ˜ฏ๏ผš

  • etcd.yaml: etcd ๆ˜ฏ Kubernetes ้›†็พค็š„ๆ•ฐๆฎๅบ“๏ผŒๅญ˜ๅ‚จไบ†้›†็พค็š„็Šถๆ€ไฟกๆฏใ€‚
  • kube-apiserver.yaml: kube-apiserver ๆ˜ฏ Kubernetes ็š„ API ๆœๅŠกๅ™จ๏ผŒ่ดŸ่ดฃๅค„็† API ่ฏทๆฑ‚ใ€‚
  • kube-controller-manager.yaml: kube-controller-manager ๆ˜ฏ Kubernetes ็š„ๆŽงๅˆถๅ™จ็ฎก็†ๅ™จ๏ผŒ่ดŸ่ดฃ็ฎก็†้›†็พค็š„ๅ„็งๆŽงๅˆถๅ™จใ€‚
  • kube-scheduler.yaml: kube-scheduler ๆ˜ฏ Kubernetes ็š„่ฐƒๅบฆๅ™จ๏ผŒ่ดŸ่ดฃๅฐ† Pod ๅˆ†้…ๅˆฐๅˆ้€‚็š„่Š‚็‚นไธŠ่ฟ่กŒใ€‚

pki

pki ็›ฎๅฝ•ๅŒ…ๅซ Kubernetes ็š„่ฏไนฆๅ’Œๅฏ†้’ฅๆ–‡ไปถ๏ผŒๅฎƒไปฌๆ˜ฏ๏ผš

  • apiserver.crt: kube-apiserver ็š„่ฏไนฆใ€‚
  • apiserver-etcd-client.crt ๅ’Œ apiserver-etcd-client.key: kube-apiserver ๅ’Œ etcd ไน‹้—ด้€šไฟก็š„่ฏไนฆๅ’Œๅฏ†้’ฅใ€‚
  • apiserver.key: kube-apiserver ็š„็ง้’ฅใ€‚
  • apiserver-kubelet-client.crt ๅ’Œ apiserver-kubelet-client.key: kube-apiserver ๅ’Œ kubelet ไน‹้—ด้€šไฟก็š„่ฏไนฆๅ’Œๅฏ†้’ฅใ€‚
  • ca.crt ๅ’Œ ca.key: Kubernetes ็š„ๆ น่ฏไนฆๅ’Œๅฏ†้’ฅใ€‚
  • etcd ็›ฎๅฝ•๏ผšetcd ็š„่ฏไนฆๅ’Œๅฏ†้’ฅๆ–‡ไปถใ€‚
  • front-proxy-ca.crt ๅ’Œ front-proxy-ca.key: ๅ‰็ฝฎไปฃ็†็š„่ฏไนฆๅ’Œๅฏ†้’ฅใ€‚
  • front-proxy-client.crt ๅ’Œ front-proxy-client.key: ๅ‰็ฝฎไปฃ็†ๅ’Œ kube-apiserver ไน‹้—ด้€šไฟก็š„่ฏไนฆๅ’Œๅฏ†้’ฅใ€‚
  • sa.key ๅ’Œ sa.pub: Kubernetes ็š„ Service Account ็š„่ฏไนฆๅ’Œๅฏ†้’ฅใ€‚

scheduler.conf

scheduler.conf ๆ˜ฏ Kubernetes ็š„่ฐƒๅบฆๅ™จ็š„้…็ฝฎๆ–‡ไปถใ€‚

่กฅๅ……

่ฟ™้‡Œๅฏไปฅๅœจ ่กฅๅ……้ƒจๅˆ† sealer ็š„ๅฎž็Žฐๅฎž็Žฐ๏ผš

::: details ๅฑ•ๅผ€ๅฆ‚ไธ‹๏ผš SaveAllๅ‡ฝๆ•ฐ็”จไบŽๅฐ†ๆ‰€ๆœ‰้…็ฝฎไฟกๆฏไฟๅญ˜ๅˆฐๆ–‡ไปถไธญใ€‚

func (c *ClusterFile) SaveAll(opts SaveOptions) error {
	var (
		clusterfileBytes [][]byte
		config           []byte
		plugin           []byte
	)
	fileName := common.GetDefaultClusterfile()
	err := os.MkdirAll(filepath.Dir(fileName), os.ModePerm)
	if err != nil {
		return fmt.Errorf("failed to mkdir %s: %v", fileName, err)
	}

	cluster, err := yaml.Marshal(c.cluster)
	if err != nil {
		return err
	}
	
	clusterfileBytes = append(clusterfileBytes, cluster)

	if len(c.configs) != 0 {
		for _, cg := range c.configs {
			config, err = yaml.Marshal(cg)
			if err != nil {
				return err
			}
			clusterfileBytes = append(clusterfileBytes, config)
		}
	}

	if len(c.plugins) != 0 {
		for _, p := range c.plugins {
			plugin, err = yaml.Marshal(p)
			if err != nil {
				return err
			}
			clusterfileBytes = append(clusterfileBytes, plugin)
		}
	}

	if len(c.kubeadmConfig.InitConfiguration.TypeMeta.Kind) != 0 {
		initConfiguration, err := yaml.Marshal(c.kubeadmConfig.InitConfiguration)
		if err != nil {
			return err
		}
		clusterfileBytes = append(clusterfileBytes, initConfiguration)
	}

	if len(c.kubeadmConfig.JoinConfiguration.TypeMeta.Kind) != 0 {
		joinConfiguration, err := yaml.Marshal(c.kubeadmConfig.JoinConfiguration)
		if err != nil {
			return err
		}
		clusterfileBytes = append(clusterfileBytes, joinConfiguration)
	}
	
	if len(c.kubeadmConfig.ClusterConfiguration.TypeMeta.Kind) != 0 {
		clusterConfiguration, err := yaml.Marshal(c.kubeadmConfig.ClusterConfiguration)
		if err != nil {
			return err
		}
		clusterfileBytes = append(clusterfileBytes, clusterConfiguration)
	}

	if len(c.kubeadmConfig.KubeletConfiguration.TypeMeta.Kind) != 0 {
		kubeletConfiguration, err := yaml.Marshal(c.kubeadmConfig.KubeletConfiguration)
		if err != nil {
			return err
		}
		clusterfileBytes = append(clusterfileBytes, kubeletConfiguration)
	}

	if len(c.kubeadmConfig.KubeProxyConfiguration.TypeMeta.Kind) != 0 {
		kubeProxyConfiguration, err := yaml.Marshal(c.kubeadmConfig.KubeProxyConfiguration)
		if err != nil {
			return err
		}
		clusterfileBytes = append(clusterfileBytes, kubeProxyConfiguration)
	}

	content := bytes.Join(clusterfileBytes, []byte("---\n"))
	err = utilsos.NewCommonWriter(fileName).WriteFile(content)
	if err != nil {
		return fmt.Errorf("failed to save clusterfile to disk:%v", err)
	}

	if opts.CommitToCluster {
		return saveToCluster(content, opts.ConfPath)
	}
	return nil
}

ๆœ‰ๆ„ๆ€็š„ๆ˜ฏ๏ผš้ƒจๅˆ†็š„ Kubernetes ็š„ไฟๅญ˜ไธญ๏ผŒconfig ๅ’Œ plug ๆ˜ฏไปฅไธ€็ปดๅˆ‡็‰‡็š„ๅฝขๅผๅญ˜ๅ‚จ็š„๏ผŒ่€ŒclusterfileBytes ็”จๆฅๆ”ถ้›† ๆ‰€ๆœ‰็š„ ๅ†…ๅฎน๏ผŒไฝฟ็”จ็š„ๆ˜ฏไบŒ็ปดๆ•ฐ็ป„็š„ๆ–นๅผๅญ˜ๅ‚จ็š„๏ผŒKubeadmConfig ๆ˜ฏ้šไพฟๅญ˜ๅ‚จ็š„ใ€‚่Žทๅ–ๅˆฐ config ๅ’Œ plug ไนŸๅชๆ˜ฏ ๅˆคๆ–ญๆ˜ฏๅฆไธบ 0

:::

END ้“พๆŽฅ