diff --git a/.gitignore b/.gitignore index c954a0f..1a13ee4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ /bin /sboms -/charts/kubernetes/Chart.lock -/charts/kubernetes/charts +/charts/application/Chart.lock +/charts/application/charts *.swp cover.out cover.html diff --git a/charts/application/Chart.lock b/charts/application/Chart.lock deleted file mode 100644 index a981fe5..0000000 --- a/charts/application/Chart.lock +++ /dev/null @@ -1,6 +0,0 @@ -dependencies: -- name: unikorn-common - repository: https://unikorn-cloud.github.io/helm-common - version: v0.1.9 -digest: sha256:e29aaa3b715a38da63e6ab2ff2a713b852fab1f51efaf07dacc32f1d9ea5283c -generated: "2024-08-28T09:53:45.835865889+01:00" diff --git a/charts/application/Chart.yaml b/charts/application/Chart.yaml index 19ab468..989ba53 100644 --- a/charts/application/Chart.yaml +++ b/charts/application/Chart.yaml @@ -11,5 +11,5 @@ icon: https://raw.githubusercontent.com/unikorn-cloud/assets/main/images/logos/d dependencies: - name: unikorn-common - version: v0.1.9 + version: v0.1.13 repository: https://unikorn-cloud.github.io/helm-common diff --git a/charts/application/charts/unikorn-common-v0.1.9.tgz b/charts/application/charts/unikorn-common-v0.1.9.tgz deleted file mode 100644 index 3e3b900..0000000 Binary files a/charts/application/charts/unikorn-common-v0.1.9.tgz and /dev/null differ diff --git a/charts/application/crds/application.unikorn-cloud.org_applicationsets.yaml b/charts/application/crds/application.unikorn-cloud.org_applicationsets.yaml new file mode 100644 index 0000000..8494fc4 --- /dev/null +++ b/charts/application/crds/application.unikorn-cloud.org_applicationsets.yaml @@ -0,0 +1,108 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.16.3 + name: applicationsets.application.unikorn-cloud.org +spec: + group: application.unikorn-cloud.org + names: + categories: + - unikorn + kind: ApplicationSet + listKind: ApplicationSetList + plural: applicationsets + singular: applicationset + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .metadata.labels['unikorn-cloud\.org/name'] + name: display name + type: string + - jsonPath: .metadata.creationTimestamp + name: age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: ApplicationSet defines a Helm application. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + properties: + pause: + description: Pause, if true, will inhibit reconciliation. + type: boolean + type: object + status: + properties: + conditions: + description: Current service state of the resource. + items: + description: |- + Condition is a generic condition type for use across all resource types. + It's generic so that the underlying controller-manager functionality can + be shared across all resources. + properties: + lastTransitionTime: + description: Last time the condition transitioned from one status + to another. + format: date-time + type: string + message: + description: Human-readable message indicating details about + last transition. + type: string + reason: + description: Unique, one-word, CamelCase reason for the condition's + last transition. + enum: + - Provisioning + - Provisioned + - Cancelled + - Errored + - Deprovisioning + - Deprovisioned + type: string + status: + description: |- + Status is the status of the condition. + Can be True, False, Unknown. + type: string + type: + description: Type is the type of the condition. + enum: + - Available + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true + subresources: {} diff --git a/charts/application/templates/application-controller/deployment.yaml b/charts/application/templates/application-controller/deployment.yaml index aa84b6d..1226477 100644 --- a/charts/application/templates/application-controller/deployment.yaml +++ b/charts/application/templates/application-controller/deployment.yaml @@ -17,6 +17,8 @@ spec: containers: - name: unikorn-application-controller image: {{ include "unikorn.applicationControllerImage" . }} + args: + {{- include "unikorn.core.flags" . | nindent 8 }} ports: - name: prometheus containerPort: 8080 diff --git a/charts/application/templates/server/deployment.yaml b/charts/application/templates/server/deployment.yaml index f4b9333..00d90d5 100644 --- a/charts/application/templates/server/deployment.yaml +++ b/charts/application/templates/server/deployment.yaml @@ -18,7 +18,7 @@ spec: - name: unikorn-application-server image: {{ include "unikorn.applicationServerImage" . }} args: - - --namespace={{ .Release.Namespace }} + {{- include "unikorn.core.flags" . | nindent 8 }} {{- include "unikorn.cors.flags" . | nindent 8 }} {{- include "unikorn.otlp.flags" . | nindent 8 }} {{- include "unikorn.identity.flags" . | nindent 8 }} diff --git a/go.mod b/go.mod index 9aaf568..2d6bb3b 100644 --- a/go.mod +++ b/go.mod @@ -7,13 +7,12 @@ require ( github.com/go-chi/chi/v5 v5.1.0 github.com/oapi-codegen/runtime v1.1.1 github.com/spf13/pflag v1.0.5 - github.com/unikorn-cloud/core v0.1.70 - github.com/unikorn-cloud/identity v0.2.36 - github.com/unikorn-cloud/kubernetes v0.2.39 - github.com/unikorn-cloud/region v0.1.40 + github.com/unikorn-cloud/core v0.1.73 + github.com/unikorn-cloud/identity v0.2.40 + github.com/unikorn-cloud/kubernetes v0.2.40 go.opentelemetry.io/otel/sdk v1.29.0 - k8s.io/api v0.31.0 - k8s.io/apimachinery v0.31.0 + k8s.io/api v0.31.1 + k8s.io/apimachinery v0.31.1 sigs.k8s.io/controller-runtime v0.19.0 ) @@ -85,7 +84,7 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/client-go v0.31.0 // indirect + k8s.io/client-go v0.31.1 // indirect k8s.io/klog/v2 v2.130.1 // indirect k8s.io/kube-openapi v0.0.0-20240827152857-f7e401e7b4c2 // indirect k8s.io/utils v0.0.0-20240821151609-f90d01438635 // indirect @@ -93,5 +92,3 @@ require ( sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) - -replace github.com/unikorn-cloud/kubernetes => github.com/unikorn-cloud/kubernetes v0.2.40-0.20241002092250-933de246e2e3 diff --git a/go.sum b/go.sum index b742b0c..fae01be 100644 --- a/go.sum +++ b/go.sum @@ -131,14 +131,12 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -github.com/unikorn-cloud/core v0.1.70 h1:WyPENhm+xLaUg2KlvSl1/eLWW/LJzJ1rJhZAe9yao0Y= -github.com/unikorn-cloud/core v0.1.70/go.mod h1:7ilhT3GIRtBHl7/D+9wh4RB5gjC/5/ts/MT4WdpIT9M= -github.com/unikorn-cloud/identity v0.2.36 h1:Wend3RI368xTObGs5lI64KsfYqpbbn9lrC63CWj3txk= -github.com/unikorn-cloud/identity v0.2.36/go.mod h1:YTKpNzo1suv3CZMbEq5Fgfvu2niyLziG9pTr6ZAfZtE= -github.com/unikorn-cloud/kubernetes v0.2.40-0.20241002092250-933de246e2e3 h1:Rw0N/F43RlEzoDmm6mnx65nxHZqMZymMS68PjyWTdKQ= -github.com/unikorn-cloud/kubernetes v0.2.40-0.20241002092250-933de246e2e3/go.mod h1:pF16DbFdrMrK+15BZJZLw8f4ZeS5/EnHYq8n6XvuuAk= -github.com/unikorn-cloud/region v0.1.40 h1:9zQu30h0z6oUpPKn7Rdml+7P2qPnYEYtk/Q/P9UuVDk= -github.com/unikorn-cloud/region v0.1.40/go.mod h1:twjAaseElxWKT4J5GjWbJkT9P2kDKuLOj/91ptmHbTY= +github.com/unikorn-cloud/core v0.1.73 h1:L819ma8BnZkYl+O0bk3kJ+ihis9jgL+8feKCC7fWzRk= +github.com/unikorn-cloud/core v0.1.73/go.mod h1:7ilhT3GIRtBHl7/D+9wh4RB5gjC/5/ts/MT4WdpIT9M= +github.com/unikorn-cloud/identity v0.2.40 h1:Y2H2cCUumDOiaCsJP5VjgVezgpB+EchZogK5Qg3G408= +github.com/unikorn-cloud/identity v0.2.40/go.mod h1:DbS+R9Om75HBQPMG02Iu3j2tjeE552KwAEcdAl5kPJE= +github.com/unikorn-cloud/kubernetes v0.2.40 h1:Cmr4RjS2CPRY++FyK7nRef3PdpD5H4ToLApzD/oAInY= +github.com/unikorn-cloud/kubernetes v0.2.40/go.mod h1:UtztUsW5plPQwS5PfDyAYlm8cNS/3MbcD5KFCtf/WeM= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -230,14 +228,14 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.31.0 h1:b9LiSjR2ym/SzTOlfMHm1tr7/21aD7fSkqgD/CVJBCo= -k8s.io/api v0.31.0/go.mod h1:0YiFF+JfFxMM6+1hQei8FY8M7s1Mth+z/q7eF1aJkTE= +k8s.io/api v0.31.1 h1:Xe1hX/fPW3PXYYv8BlozYqw63ytA92snr96zMW9gWTU= +k8s.io/api v0.31.1/go.mod h1:sbN1g6eY6XVLeqNsZGLnI5FwVseTrZX7Fv3O26rhAaI= k8s.io/apiextensions-apiserver v0.31.0 h1:fZgCVhGwsclj3qCw1buVXCV6khjRzKC5eCFt24kyLSk= k8s.io/apiextensions-apiserver v0.31.0/go.mod h1:b9aMDEYaEe5sdK+1T0KU78ApR/5ZVp4i56VacZYEHxk= -k8s.io/apimachinery v0.31.0 h1:m9jOiSr3FoSSL5WO9bjm1n6B9KROYYgNZOb4tyZ1lBc= -k8s.io/apimachinery v0.31.0/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= -k8s.io/client-go v0.31.0 h1:QqEJzNjbN2Yv1H79SsS+SWnXkBgVu4Pj3CJQgbx0gI8= -k8s.io/client-go v0.31.0/go.mod h1:Y9wvC76g4fLjmU0BA+rV+h2cncoadjvjjkkIGoTLcGU= +k8s.io/apimachinery v0.31.1 h1:mhcUBbj7KUjaVhyXILglcVjuS4nYXiwC+KKFBgIVy7U= +k8s.io/apimachinery v0.31.1/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= +k8s.io/client-go v0.31.1 h1:f0ugtWSbWpxHR7sjVpQwuvw9a3ZKLXX0u0itkFXufb0= +k8s.io/client-go v0.31.1/go.mod h1:sKI8871MJN2OyeqRlmA4W4KM9KBdBUpDLu/43eGemCg= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20240827152857-f7e401e7b4c2 h1:GKE9U8BH16uynoxQii0auTjmmmuZ3O0LFMN6S0lPPhI= diff --git a/pkg/apis/unikorn/v1alpha1/types.go b/pkg/apis/unikorn/v1alpha1/types.go index 6bcdeeb..516d622 100644 --- a/pkg/apis/unikorn/v1alpha1/types.go +++ b/pkg/apis/unikorn/v1alpha1/types.go @@ -32,9 +32,8 @@ type ApplicationSetList struct { // ApplicationSet defines a Helm application. // +genclient -// +genclient:nonNamespaced // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +kubebuilder:resource:scope=Cluster,categories=unikorn +// +kubebuilder:resource:scope=Namespaced,categories=unikorn // +kubebuilder:printcolumn:name="display name",type="string",JSONPath=".metadata.labels['unikorn-cloud\\.org/name']" // +kubebuilder:printcolumn:name="age",type="date",JSONPath=".metadata.creationTimestamp" type ApplicationSet struct { diff --git a/pkg/provisioners/managers/application/provisioner.go b/pkg/provisioners/managers/application/provisioner.go index 352fb40..3e76e4f 100644 --- a/pkg/provisioners/managers/application/provisioner.go +++ b/pkg/provisioners/managers/application/provisioner.go @@ -89,6 +89,8 @@ func (p *Provisioner) Object() unikornv1core.ManagableResourceInterface { // getKubernetesClient returns an authenticated context with a client credentials access token // and a client. The context must be used by subseqent API calls in order to extract // the access token. +// +//nolint:unparam func (p *Provisioner) getKubernetesClient(ctx context.Context, traceName string) (context.Context, kubernetesapi.ClientWithResponsesInterface, error) { cli, err := coreclient.ProvisionerClientFromContext(ctx) if err != nil { @@ -114,22 +116,26 @@ func (p *Provisioner) getKubernetesClient(ctx context.Context, traceName string) // Provision implements the Provision interface. func (p *Provisioner) Provision(ctx context.Context) error { - _, _, err := p.getKubernetesClient(ctx, "provision") + clientContext, client, err := p.getKubernetesClient(ctx, "provision") if err != nil { return err } // TODO: do something! + _, _ = clientContext, client + return nil } // Deprovision implements the Provision interface. func (p *Provisioner) Deprovision(ctx context.Context) error { - // TODO: do something! - _, _, err := p.getKubernetesClient(ctx, "deprovision") + clientContext, client, err := p.getKubernetesClient(ctx, "deprovision") if err != nil { return err } + // TODO: do something! + _, _ = clientContext, client + return nil } diff --git a/pkg/server/handler/options.go b/pkg/server/handler/options.go index 989bd58..d937a62 100644 --- a/pkg/server/handler/options.go +++ b/pkg/server/handler/options.go @@ -20,8 +20,6 @@ import ( "time" "github.com/spf13/pflag" - - "github.com/unikorn-cloud/kubernetes/pkg/server/handler/cluster" ) // Options defines configurable handler options. @@ -29,14 +27,9 @@ type Options struct { // cacheMaxAge defines the max age for cachable items e.g. images and // flavors don't change all that often. CacheMaxAge time.Duration - - // Cluster is a set of options for managed clusters. - Cluster cluster.Options } // AddFlags adds the options flags to the given flag set. func (o *Options) AddFlags(f *pflag.FlagSet) { f.DurationVar(&o.CacheMaxAge, "cache-max-age", 24*time.Hour, "How long to cache long-lived queries in the browser.") - - o.Cluster.AddFlags(f) }