-
Notifications
You must be signed in to change notification settings - Fork 3
π€ feat: single-binary dual application (controller + aggregated API server) #11
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 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e05daba
refactor: extract controller app and add app mode dispatch
ThomasK33 aaf628d
feat: add aggregation API types and deepcopy generation
ThomasK33 f5aa191
feat: implement aggregated apiserver wiring and storage
ThomasK33 0d72dbb
chore: vendor k8s.io/apiserver and transitive dependencies
ThomasK33 a4ed778
fix: register v1 meta types and SingularNameProvider for aggregated Aβ¦
ThomasK33 85b9d23
fix: add controller service account and reference in deployment
ThomasK33 8405dd2
fix: add controller ClusterRole and ClusterRoleBinding for CoderContrβ¦
ThomasK33 b22b053
style: fix gofumpt formatting and add missing package comments
ThomasK33 44fbc93
style: apply gofumpt -extra formatting for same-type parameter grouping
ThomasK33 e6a93a9
chore: remove accidental vendor stamp file
ThomasK33 5e08e6a
fix: add --app=controller arg to e2e deployment manifest
ThomasK33 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| // Package v1alpha1 contains API schema definitions for the aggregation.coder.com API group. | ||
| // | ||
| // +k8s:deepcopy-gen=package | ||
| // +groupName=aggregation.coder.com | ||
| package v1alpha1 |
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,34 @@ | ||
| package v1alpha1 | ||
|
|
||
| import ( | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
| "k8s.io/apimachinery/pkg/runtime/schema" | ||
| ) | ||
|
|
||
| var ( | ||
| // SchemeGroupVersion is group version used to register these objects. | ||
| SchemeGroupVersion = schema.GroupVersion{Group: "aggregation.coder.com", Version: "v1alpha1"} | ||
|
|
||
| // SchemeBuilder is used to add go types to the GroupVersionKind scheme. | ||
| SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) | ||
|
|
||
| // AddToScheme adds the types in this group-version to the provided scheme. | ||
| AddToScheme = SchemeBuilder.AddToScheme | ||
| ) | ||
|
|
||
| func addKnownTypes(scheme *runtime.Scheme) error { | ||
| scheme.AddKnownTypes(SchemeGroupVersion, | ||
| &CoderWorkspace{}, | ||
| &CoderWorkspaceList{}, | ||
| &CoderTemplate{}, | ||
| &CoderTemplateList{}, | ||
| ) | ||
| metav1.AddToGroupVersion(scheme, SchemeGroupVersion) | ||
| return nil | ||
| } | ||
|
|
||
| // Resource takes an unqualified resource and returns a Group-qualified GroupResource. | ||
| func Resource(resource string) schema.GroupResource { | ||
| return SchemeGroupVersion.WithResource(resource).GroupResource() | ||
| } |
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,73 @@ | ||
| package v1alpha1 | ||
|
|
||
| import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
|
||
| // CoderWorkspaceSpec defines the desired state of a CoderWorkspace. | ||
| type CoderWorkspaceSpec struct { | ||
| // Running indicates whether the workspace should be running. | ||
| Running bool `json:"running"` | ||
| } | ||
|
|
||
| // CoderWorkspaceStatus defines the observed state of a CoderWorkspace. | ||
| type CoderWorkspaceStatus struct { | ||
| // AutoShutdown is the next planned shutdown time for the workspace. | ||
| AutoShutdown *metav1.Time `json:"autoShutdown,omitempty"` | ||
| } | ||
|
|
||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:subresource:status | ||
|
|
||
| // CoderWorkspace is the schema for Coder workspace resources. | ||
| type CoderWorkspace struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| Spec CoderWorkspaceSpec `json:"spec,omitempty"` | ||
| Status CoderWorkspaceStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
| // +kubebuilder:object:root=true | ||
|
|
||
| // CoderWorkspaceList contains a list of CoderWorkspace objects. | ||
| type CoderWorkspaceList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []CoderWorkspace `json:"items"` | ||
| } | ||
|
|
||
| // CoderTemplateSpec defines the desired state of a CoderTemplate. | ||
| type CoderTemplateSpec struct { | ||
| // Running indicates whether the template should be marked as running. | ||
| Running bool `json:"running"` | ||
| } | ||
|
|
||
| // CoderTemplateStatus defines the observed state of a CoderTemplate. | ||
| type CoderTemplateStatus struct { | ||
| // AutoShutdown is the next planned shutdown time for workspaces created by this template. | ||
| AutoShutdown *metav1.Time `json:"autoShutdown,omitempty"` | ||
| } | ||
|
|
||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:subresource:status | ||
|
|
||
| // CoderTemplate is the schema for Coder template resources. | ||
| type CoderTemplate struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| Spec CoderTemplateSpec `json:"spec,omitempty"` | ||
| Status CoderTemplateStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
| // +kubebuilder:object:root=true | ||
|
|
||
| // CoderTemplateList contains a list of CoderTemplate objects. | ||
| type CoderTemplateList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []CoderTemplate `json:"items"` | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,36 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "flag" | ||
| "fmt" | ||
|
|
||
| ctrl "sigs.k8s.io/controller-runtime" | ||
|
|
||
| "github.com/coder/coder-k8s/internal/app/apiserverapp" | ||
| "github.com/coder/coder-k8s/internal/app/controllerapp" | ||
| ) | ||
|
|
||
| var ( | ||
| runControllerApp = controllerapp.Run | ||
| runAggregatedAPIServerApp = apiserverapp.Run | ||
| ) | ||
|
|
||
| func run(args []string) error { | ||
| fs := flag.NewFlagSet("coder-k8s", flag.ContinueOnError) | ||
| var appMode string | ||
| fs.StringVar(&appMode, "app", "", "Application mode (controller, aggregated-apiserver)") | ||
| if err := fs.Parse(args); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| switch appMode { | ||
| case "controller": | ||
| return runControllerApp(ctrl.SetupSignalHandler()) | ||
| case "aggregated-apiserver": | ||
| return runAggregatedAPIServerApp(ctrl.SetupSignalHandler()) | ||
| case "": | ||
| return fmt.Errorf("assertion failed: --app flag is required; must be one of: controller, aggregated-apiserver") | ||
| default: | ||
| return fmt.Errorf("assertion failed: unsupported --app value %q; must be one of: controller, aggregated-apiserver", appMode) | ||
| } | ||
| } | ||
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,13 @@ | ||
| apiVersion: apiregistration.k8s.io/v1 | ||
| kind: APIService | ||
| metadata: | ||
| name: v1alpha1.aggregation.coder.com | ||
| spec: | ||
| group: aggregation.coder.com | ||
| version: v1alpha1 | ||
| service: | ||
| name: coder-k8s-apiserver | ||
| namespace: coder-system | ||
| groupPriorityMinimum: 1000 | ||
| versionPriority: 100 | ||
| insecureSkipTLSVerify: true |
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,23 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: coder-k8s-apiserver | ||
| namespace: coder-system | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| app: coder-k8s-apiserver | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: coder-k8s-apiserver | ||
| spec: | ||
| serviceAccountName: coder-k8s-apiserver | ||
| containers: | ||
| - name: apiserver | ||
| image: ghcr.io/coder/coder-k8s:latest | ||
| args: ["--app=aggregated-apiserver"] | ||
| ports: | ||
| - containerPort: 6443 | ||
| name: https |
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.