Skip to content

Commit

Permalink
Merge pull request #1847 from rancher/config-v1-updates
Browse files Browse the repository at this point in the history
Config v1 updates
  • Loading branch information
kralicky authored Nov 21, 2023
2 parents 473bf8f + eb1d210 commit bc973a3
Show file tree
Hide file tree
Showing 10 changed files with 2,515 additions and 976 deletions.
78 changes: 78 additions & 0 deletions apis/core/v1/gateway_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package v1

import (
configv1 "github.com/rancher/opni/pkg/config/v1"
opnimeta "github.com/rancher/opni/pkg/util/meta"
"google.golang.org/protobuf/proto"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

type GatewaySpec struct {
Replicas *int32 `json:"replicas,omitempty"`
Image *opnimeta.ImageSpec `json:"image,omitempty"`
AgentImageTagOverride string `json:"agentImageTagOverride,omitempty"`
NatsRef corev1.LocalObjectReference `json:"natsCluster"`
ServiceType corev1.ServiceType `json:"serviceType,omitempty"`
ServiceAnnotations map[string]string `json:"serviceAnnotations,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
ExtraVolumeMounts []opnimeta.ExtraVolumeMount `json:"extraVolumeMounts,omitempty"`
ExtraEnvVars []corev1.EnvVar `json:"extraEnvVars,omitempty"`

//+kubebuilder:validation:Schemaless
//+kubebuilder:pruning:PreserveUnknownFields
//+kubebuilder:validation:Type=object
Config *configv1.GatewayConfigSpec `json:"config,omitempty"`
}

type GatewayStatus struct {
Image string `json:"image,omitempty"`
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
ServiceName string `json:"serviceName,omitempty"`
LoadBalancer *corev1.LoadBalancerIngress `json:"loadBalancer,omitempty"`
Endpoints []corev1.EndpointAddress `json:"endpoints,omitempty"`
Ready bool `json:"ready,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
type Gateway struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec GatewaySpec `json:"spec,omitempty"`
Status GatewayStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
type GatewayList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Gateway `json:"items"`
}

func init() {
SchemeBuilder.Register(
&Gateway{}, &GatewayList{},
)
}

type ValueStoreMethods struct{}

// ControllerReference implements crds.ValueStoreMethods.
func (m ValueStoreMethods) ControllerReference() (client.Object, bool) {
return nil, false // Gateway is a top-level object
}

// FillConfigFromObject implements crds.ValueStoreMethods.
func (ValueStoreMethods) FillConfigFromObject(obj *Gateway, conf *configv1.GatewayConfigSpec) {
proto.Merge(conf, obj.Spec.Config)
}

// FillObjectFromConfig implements crds.ValueStoreMethods.
func (ValueStoreMethods) FillObjectFromConfig(obj *Gateway, conf *configv1.GatewayConfigSpec) {
obj.Spec.Config = conf
obj.Spec.Config.Revision = nil
}
19 changes: 19 additions & 0 deletions apis/core/v1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// +kubebuilder:object:generate=true
// +groupName=core.opni.io
package v1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "core.opni.io", Version: "v1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
182 changes: 182 additions & 0 deletions apis/core/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bc973a3

Please sign in to comment.