-
Notifications
You must be signed in to change notification settings - Fork 9
Implement (simplified) Deployment controller and its model #611
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
Merged
Merged
Changes from all commits
Commits
Show all changes
98 commits
Select commit
Hold shift + click to select a range
38a1b38
do not use docker builder
Catoverflow 8653d86
fix sed in conformance test
Catoverflow 8d9971e
add instructions of scripts
Catoverflow 4f2c1a8
Minor fix of format
Catoverflow e9e1163
deployment controller skeleton init
Catoverflow 983b1e4
add dc controller doc
Catoverflow 519df71
add note on controlled rs
Catoverflow 5799c7a
complete skeleton, model to be fulfulled
Catoverflow a50b420
add todo
Catoverflow 94213cd
add corresponding model
Catoverflow 7a71242
evolve over the spec for dc
Catoverflow 24b0021
model for vdeployment controller complete, proceed to executable part
Catoverflow 5eda9ee
add exec part for vdeployment controller
Catoverflow 1b59982
update state machine model
Catoverflow 39ec390
hack vd dependency, bugs fix, update reconciler to match new state ma…
Catoverflow 5b5b6a1
add clone trait for vrs, bugs fix for vd
Catoverflow 2c7182d
bugs fix; mask Option<replicas>, reconcile_core postcondition for the…
Catoverflow 8025a91
bugs fix, unmask problems
Catoverflow dc2d225
changes made during the meeting
Catoverflow f2135d4
add Default for VRSSpec, move seq_filter_implies_contains to vstd_ext…
Catoverflow a3940e5
prove objects_to_vrs_list by reusing the proof for objects_to_pods
Catoverflow 9f362bc
get rid of old lemma
Catoverflow 2364db4
fed up with silly proofs
Catoverflow c7ad6e7
followup with the spec change
Catoverflow 9adb16c
rewrite filter_old_and_new_vrs to follow the spec pattern, also try t…
Catoverflow 1746219
no progress on make_replica_set
Catoverflow 62a7d84
fix filter_vrs_list and Clone trait for VRS
codyjrivera 4622b74
bug fix of inconsistency between - and _
Catoverflow 17b9aa8
change filter_old_and_new_vrs signature, prove it
Catoverflow 1892304
add well_formed to ObjevtMeta and VReplicaSet exec, prove VD
Catoverflow 917b11a
add e2e test for VDeployment controller
Catoverflow 8bb6691
remove duplicated e2e test
Catoverflow f916057
fix e2e bug partially
Catoverflow 3f55127
support dual deploy for vd and vrs
Catoverflow da9319e
add vrs crd as required by vd
Catoverflow c3b64da
e2e test bug fix
Catoverflow 8ae6f13
typo fix
Catoverflow d6f9169
add vrs controller to vd e2e deploy
Catoverflow f944cec
fix crd bug
Catoverflow db7f8c8
add a --no-build option so vargo will not always rebuild, causing doc…
Catoverflow 4c3dd3f
bug fix
Catoverflow 9f13857
bug fix, should move to new vd controller model later
Catoverflow 0f7ec51
fixes according to Cody's suggestion
Catoverflow d079ce1
fix bug in e2e test, add unset method in object_meta
Catoverflow 1c8cb2a
prove vd
Catoverflow eca80e8
strengthen state_validation (which can be proved from the current def…
Catoverflow 9c0dfd2
add remove support
Catoverflow eb7a35d
make implicit result explicit for the ease of proof, which further st…
Catoverflow 54e5c23
fix proof for vd
Catoverflow 93b4b3c
add hash to vrs labels to follow k8s impl
Catoverflow 9691bbf
fix inconsistency in labels added
Catoverflow 32ea47c
add vd support after rebase
Catoverflow 8989954
fix state machine
Catoverflow ed3a949
change no-build to be reusing existing docker image instead of contro…
Catoverflow 9c19aa8
e2e passed; add template patch test
Catoverflow 21dd055
add back loop in state machine
Catoverflow ab8494c
add triggers
Catoverflow ec75489
switch back to original model after bugs are identified
Catoverflow e22356c
fix proof
Catoverflow d23b80a
fix vd controller state machine
Catoverflow e9cabd4
fix vd e2e test ci
Catoverflow 424dcd5
fix wrong commit picked during rebase
Catoverflow e0e50da
add log on correct res
Catoverflow b2c73cc
move cluster setup to deploy.sh for the ease of local test
Catoverflow 75e0605
add more complicated and powerful
Catoverflow 2b5b72f
fix admission controller test, we may want to merge them into e2e/ an…
Catoverflow eb13404
move cluster name to deploy.sh
Catoverflow e744b02
remove stale comment
Catoverflow c26007b
fix PR comments
Catoverflow 3fd6c1b
move state machine to comment to make it easier to maintain consistency
Catoverflow c7c7fc9
fix postcondition
Catoverflow 802550e
temporary fix for vrs.state_validation(), permenant fix should be pro…
Catoverflow f830f7d
rewrite vdeployment controller by vibe coding
Catoverflow 9e821a8
proved 3 wrapper funcs
Catoverflow 4f9ee49
add ref macro support
Catoverflow e8f669a
prove vd
Catoverflow d8209c6
add todo
Catoverflow 5c06c37
add ESR for vd
Catoverflow d56bb1f
remove admission controller accidentally introduced during rebase
Catoverflow 7ed6ae7
fix unfixed conflict left during rebase
Catoverflow 2e1d91e
try to unify admission test (again)
Catoverflow 770f604
try to merge admission test workflow to deploy.sh
Catoverflow 0f9e2d8
remove unused validation introduced during rebase
Catoverflow 7ed4d84
as map::empty() is no longer used, remove the comment
Catoverflow 635882f
use default trait
Catoverflow ab124fd
fix ci
Catoverflow 63ad822
fix admission controller testflow
Catoverflow d23f1c8
remove unused imports, temporarily fix flaky proof in VRS
Catoverflow 2374736
move namespace.is_Some into CR's requirements; unset_label -> remove_…
Catoverflow 81e5fef
add vd.state_validation; add comment on TODO in vd; fix comment in vrs
Catoverflow 5b633e0
fix calling is_Some in exec code, which was masked by #[verifier(exte…
Catoverflow c0a77a0
follow up with changes on main(again), use deep view
Catoverflow 7eabc26
prove reconcile_init_state
Catoverflow 96cc751
vd.spec.template and vrs.spec.template are required
Catoverflow 89befe5
remove accidentally introduced error log
Catoverflow e6ca625
fix e2e test
Catoverflow 7710a19
make vrs.spec.template optional to be consistent with k8s-oneapi spec
Catoverflow ff7e62d
noop to trigger ci
Catoverflow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -405,13 +405,7 @@ jobs: | |
- name: Install kind | ||
run: go install sigs.k8s.io/kind@v$kind_version | ||
- name: Deploy vreplicaset admission controller | ||
run: | | ||
VERUS_DIR="${HOME}/verus" ./build.sh v2_vreplicaset_admission_controller.rs --no-verify --time | ||
docker build -f docker/controller/Dockerfile.local -t local/admission-controller:v0.1.0 --build-arg APP=v2_vreplicaset_admission . | ||
kind create cluster --config deploy/kind.yaml | ||
kind load docker-image local/admission-controller:v0.1.0 | ||
cd e2e | ||
./admission_setup.sh vreplicaset | ||
run: VERUS_DIR="${HOME}/verus" ./local-test.sh v2-vreplicaset-admission --build | ||
- name: Run vreplicaset e2e tests for admission | ||
run: . "$HOME/.cargo/env" && cd e2e && cargo run -- v2-vreplicaset-admission | ||
vstatefulset-admission-e2e-test: | ||
|
@@ -436,13 +430,7 @@ jobs: | |
- name: Install kind | ||
run: go install sigs.k8s.io/kind@v$kind_version | ||
- name: Deploy vstatefulset admission controller | ||
run: | | ||
VERUS_DIR="${HOME}/verus" ./build.sh v2_vstatefulset_admission_controller.rs --no-verify --time | ||
docker build -f docker/controller/Dockerfile.local -t local/admission-controller:v0.1.0 --build-arg APP=v2_vstatefulset_admission . | ||
kind create cluster --config deploy/kind.yaml | ||
kind load docker-image local/admission-controller:v0.1.0 | ||
cd e2e | ||
./admission_setup.sh vstatefulset | ||
run: VERUS_DIR="${HOME}/verus" ./local-test.sh v2-vstatefulset-admission --build | ||
- name: Run vstatefulset e2e tests for admission | ||
run: . "$HOME/.cargo/env" && cd e2e && cargo run -- v2-vstatefulset-admission | ||
vreplicaset-e2e-test: | ||
|
@@ -470,3 +458,29 @@ jobs: | |
run: VERUS_DIR="${HOME}/verus" ./local-test.sh v2-vreplicaset --build-remote | ||
- name: Run vreplicaset e2e tests | ||
run: . "$HOME/.cargo/env" && cd e2e && cargo run -- v2-vreplicaset | ||
vdeployment-e2e-test: | ||
needs: | ||
- build-and-cache-verus | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Restore Verus cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
${{ env.home_dir }}/verus/source | ||
${{ env.home_dir }}/verus/dependencies | ||
${{ env.home_dir }}/.cargo | ||
${{ env.home_dir }}/.rustup | ||
key: verus-${{ runner.os }}-${{ env.verus_commit }}-${{ hashFiles('rust-toolchain.toml') }} | ||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "^1.20" | ||
- name: Install kind | ||
run: go install sigs.k8s.io/[email protected] | ||
- name: Deploy v2-vdeployment controller | ||
run: VERUS_DIR="${HOME}/verus" ./local-test.sh v2-vdeployment --build | ||
- name: Run vdeployment e2e tests | ||
run: . "$HOME/.cargo/env" && cd e2e && cargo run -- v2-vdeployment | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../v2_vreplicaset/crd.yaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: v2-vdeployment-controller | ||
namespace: v2-vdeployment | ||
labels: | ||
app.kubernetes.io/name: v2-vdeployment-controller | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: v2-vdeployment-controller | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: v2-vdeployment-controller | ||
spec: | ||
containers: | ||
- image: local/v2-vdeployment-controller:v0.1.0 | ||
imagePullPolicy: IfNotPresent | ||
name: controller | ||
serviceAccountName: v2-vdeployment-controller | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: v2-vreplicaset-controller | ||
namespace: v2-vdeployment | ||
labels: | ||
app.kubernetes.io/name: v2-vreplicaset-controller | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: v2-vreplicaset-controller | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: v2-vreplicaset-controller | ||
spec: | ||
containers: | ||
- image: local/v2-vreplicaset-controller:v0.1.0 | ||
imagePullPolicy: IfNotPresent | ||
name: controller | ||
serviceAccountName: v2-vdeployment-controller |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: v2-vdeployment-controller | ||
namespace: v2-vdeployment | ||
labels: | ||
app.kubernetes.io/name: v2-vdeployment-controller | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: v2-vdeployment-controller | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: v2-vdeployment-controller | ||
spec: | ||
containers: | ||
- image: ghcr.io/anvil-verifier/anvil/v2-vdeployment-controller:latest | ||
name: controller | ||
serviceAccountName: v2-vdeployment-controller | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: v2-vreplicaset-controller | ||
namespace: v2-vdeployment | ||
labels: | ||
app.kubernetes.io/name: v2-vreplicaset-controller | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: v2-vreplicaset-controller | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: v2-vreplicaset-controller | ||
spec: | ||
containers: | ||
- image: ghcr.io/anvil-verifier/anvil/v2-vreplicaset-controller:latest | ||
name: controller | ||
serviceAccountName: v2-vdeployment-controller |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: v2-vdeployment | ||
name: v2-vdeployment | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: v2-vdeployment-controller | ||
namespace: v2-vdeployment | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: v2-vdeployment-controller | ||
name: v2-vdeployment-controller-role | ||
rules: | ||
- apiGroups: | ||
- anvil.dev | ||
resources: | ||
- "*" | ||
verbs: | ||
- "*" | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods | ||
- replicasets | ||
- services | ||
- endpoints | ||
- persistentvolumeclaims | ||
- events | ||
- configmaps | ||
- secrets | ||
- serviceaccounts | ||
verbs: | ||
- "*" | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: v2-vdeployment-controller | ||
name: v2-vdeployment-controller-rolebinding | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: v2-vdeployment-controller-role | ||
subjects: | ||
- kind: ServiceAccount | ||
name: v2-vdeployment-controller | ||
namespace: v2-vdeployment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: anvil.dev/v1 | ||
kind: VDeployment | ||
metadata: | ||
name: pause-deployment | ||
labels: | ||
app: pause-demo | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: pause-demo | ||
template: | ||
metadata: | ||
labels: | ||
app: pause-demo | ||
spec: | ||
containers: | ||
- name: pause | ||
image: k8s.gcr.io/pause:3.9 | ||
Catoverflow marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Deployment Controller (DC) | ||
|
||
## Reconciliation Login | ||
|
||
> In `pkg/controller/deployment/deployment_controller.go` | ||
|
||
Reconciliation is performed by `syncDeployment`, which can be modeled as state machine: | ||
|
||
0. Orphaning, adoption. This one is not considered in the model | ||
|
||
1. [List all replicasets](https://github.com/kubernetes/kubernetes/blob/cdc807a9e849b651fb48c962cc18e25d39ec5edf/pkg/controller/deployment/deployment_controller.go#L629) (RS) owned by this DC from API Server | ||
|
||
2. [Get all pods](https://github.com/kubernetes/kubernetes/blob/cdc807a9e849b651fb48c962cc18e25d39ec5edf/pkg/controller/deployment/deployment_controller.go#L638) managed by controlled RS and create a RS-pod map from API Server | ||
|
||
3. Make decision on how to manage controlled RS: | ||
x. Rollback, not considered in the model | ||
Compare managed RS template and DC template, | ||
**A**. if the number of replica is different, this is a [scaling event](https://github.com/kubernetes/kubernetes/blob/cdc807a9e849b651fb48c962cc18e25d39ec5edf/pkg/controller/deployment/deployment_controller.go#L665), just scale up/down the single newest controlled RS | ||
**B**. The application managed* by DC should be updated (`spec.template.container`). Based on the configured update policy**: | ||
|
||
I. [rollout](https://github.com/kubernetes/kubernetes/blob/cdc807a9e849b651fb48c962cc18e25d39ec5edf/pkg/controller/deployment/rolling.go#L31): (Create if non-existing and) scale up new RS, then scale down old RS | ||
II. [recreate](https://github.com/kubernetes/kubernetes/blob/cdc807a9e849b651fb48c962cc18e25d39ec5edf/pkg/controller/deployment/recreate.go#L29): Scale down old RS, then (create if non-existing and) scale up the new RS. | ||
|
||
--- | ||
|
||
*: The deployment controller will only control at most one new replica set, and multiple old replica sets | ||
|
||
> In k8s implementation it's [possible](https://github.com/kubernetes/kubernetes/blob/cdc807a9e849b651fb48c962cc18e25d39ec5edf/pkg/controller/deployment/util/deployment_util.go#L633-L634) to have multiple new replica sets in rare cases | ||
|
||
**: The scale up/down process should satisfy `maxSurge` and `maxUnavailable` properties of DC, which means DC may not scale the controlled new & old RS to desired replicas in one step. Instead DC will scale up & down gradually in turn. Currently we do not model this feature. | ||
Catoverflow marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.