-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start definition of VStatefulSet in Anvil
Signed-off-by: Cody Rivera <[email protected]>
- Loading branch information
1 parent
c6c47af
commit cf97207
Showing
7 changed files
with
293 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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,91 @@ | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: vstatefulsets.anvil.dev | ||
spec: | ||
group: anvil.dev | ||
names: | ||
categories: [] | ||
kind: VStatefulSet | ||
plural: vstatefulsets | ||
shortNames: | ||
- vsts | ||
singular: vstatefulset | ||
scope: Namespaced | ||
versions: | ||
- additionalPrinterColumns: [] | ||
name: v1 | ||
schema: | ||
openAPIV3Schema: | ||
description: "Auto-generated derived type for VStatefulSetSpec via `CustomResource`" | ||
properties: | ||
spec: | ||
properties: | ||
minReadySeconds: | ||
format: int32 | ||
type: integer | ||
podManagementPolicy: | ||
type: string | ||
replicas: | ||
format: int32 | ||
type: integer | ||
revisionHistoryLimit: | ||
format: int32 | ||
type: integer | ||
serviceName: | ||
type: string | ||
required: | ||
- minReadySeconds | ||
- podManagementPolicy | ||
- replicas | ||
- revisionHistoryLimit | ||
- serviceName | ||
type: object | ||
status: | ||
nullable: true | ||
properties: | ||
availableReplicas: | ||
format: int32 | ||
type: integer | ||
collisionCount: | ||
format: int32 | ||
type: integer | ||
currentReplicas: | ||
format: int32 | ||
type: integer | ||
currentRevision: | ||
type: string | ||
observedGeneration: | ||
format: int64 | ||
type: integer | ||
readyReplicas: | ||
format: int32 | ||
type: integer | ||
replicas: | ||
format: int32 | ||
type: integer | ||
updateRevision: | ||
type: string | ||
updatedReplicas: | ||
format: int32 | ||
type: integer | ||
required: | ||
- availableReplicas | ||
- collisionCount | ||
- currentReplicas | ||
- currentRevision | ||
- observedGeneration | ||
- readyReplicas | ||
- replicas | ||
- updateRevision | ||
- updatedReplicas | ||
type: object | ||
required: | ||
- spec | ||
title: VStatefulSet | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} | ||
|
This file contains 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,22 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: vstatefulset-controller | ||
namespace: vstatefulset | ||
labels: | ||
app.kubernetes.io/name: vstatefulset-controller | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: vstatefulset-controller | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: vstatefulset-controller | ||
spec: | ||
containers: | ||
- image: local/vstatefulset-controller:v0.1.0 | ||
imagePullPolicy: IfNotPresent | ||
name: controller | ||
serviceAccountName: vstatefulset-controller |
This file contains 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,69 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: vstatefulset | ||
name: vstatefulset | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: vstatefulset-controller | ||
namespace: vstatefulset | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: vstatefulset-controller | ||
name: vstatefulset-controller-role | ||
rules: | ||
- apiGroups: | ||
- anvil.dev | ||
resources: | ||
- "*" | ||
verbs: | ||
- "*" | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods | ||
- services | ||
- endpoints | ||
- persistentvolumeclaims | ||
- events | ||
- configmaps | ||
- secrets | ||
- serviceaccounts | ||
verbs: | ||
- "*" | ||
- apiGroups: | ||
- apps | ||
resources: | ||
- deployments | ||
- daemonsets | ||
- replicasets | ||
- statefulsets | ||
verbs: | ||
- "*" | ||
- apiGroups: | ||
- policy | ||
resources: | ||
- poddisruptionbudgets | ||
verbs: | ||
- "*" | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: vstatefulset-controller | ||
name: vstatefulset-controller-rolebinding | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: vstatefulset-controller-role | ||
subjects: | ||
- kind: ServiceAccount | ||
name: vstatefulset-controller | ||
namespace: vstatefulset |
This file contains 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,12 @@ | ||
apiVersion: anvil.dev/v1 | ||
kind: VStatefulSet | ||
metadata: | ||
name: vstatefulset | ||
namespace: default | ||
spec: | ||
serviceName: foo | ||
replicas: 4 | ||
podManagementPolicy: dummy | ||
revisionHistoryLimit: 4 | ||
minReadySeconds: 42 | ||
|
This file contains 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 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,48 @@ | ||
// Copyright 2024 VMware, Inc. | ||
// SPDX-License-Identifier: MIT | ||
#![allow(unused_imports)] | ||
|
||
pub mod external_api; | ||
pub mod kubernetes_api_objects; | ||
pub mod kubernetes_cluster; | ||
pub mod reconciler; | ||
pub mod shim_layer; | ||
pub mod state_machine; | ||
pub mod temporal_logic; | ||
pub mod vstd_ext; | ||
|
||
use builtin::*; | ||
use builtin_macros::*; | ||
|
||
use crate::external_api::exec::*; | ||
use deps_hack::anyhow::Result; | ||
use deps_hack::futures; | ||
use deps_hack::kube::CustomResourceExt; | ||
use deps_hack::serde_yaml; | ||
use deps_hack::tokio; | ||
use shim_layer::controller_runtime::run_controller; | ||
use std::env; | ||
|
||
verus! { | ||
|
||
#[verifier(external)] | ||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let args: Vec<String> = env::args().collect(); | ||
let cmd = args[1].clone(); | ||
|
||
if cmd == String::from("export") { | ||
println!("exporting custom resource definition"); | ||
println!("{}", serde_yaml::to_string(&deps_hack::VStatefulSet::crd())?); | ||
} else if cmd == String::from("run") { | ||
println!("running vstatefulset-controller"); | ||
println!("controller terminated"); | ||
} else if cmd == String::from("crash") { | ||
println!("running vstatefulset-controller in crash-testing mode"); | ||
println!("controller terminated"); | ||
} else { | ||
println!("wrong command; please use \"export\", \"run\" or \"crash\""); | ||
} | ||
Ok(()) | ||
} | ||
} |