Skip to content

Commit

Permalink
Provide Some Base Fixes (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
spjmurray authored Oct 3, 2024
1 parent ca7806f commit b29d7f4
Show file tree
Hide file tree
Showing 12 changed files with 142 additions and 45 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
6 changes: 0 additions & 6 deletions charts/application/Chart.lock

This file was deleted.

2 changes: 1 addition & 1 deletion charts/application/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file removed charts/application/charts/unikorn-common-v0.1.9.tgz
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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: {}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/application/templates/server/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
15 changes: 6 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -85,13 +84,11 @@ 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
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
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
26 changes: 12 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
3 changes: 1 addition & 2 deletions pkg/apis/unikorn/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 9 additions & 3 deletions pkg/provisioners/managers/application/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
7 changes: 0 additions & 7 deletions pkg/server/handler/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,16 @@ import (
"time"

"github.com/spf13/pflag"

"github.com/unikorn-cloud/kubernetes/pkg/server/handler/cluster"
)

// Options defines configurable handler options.
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)
}

0 comments on commit b29d7f4

Please sign in to comment.