Skip to content
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

Add yurtappoverrider #1684

Merged
merged 22 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions charts/yurt-manager/crds/apps.openyurt.io_yurtappoverriders.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.7.0
creationTimestamp: null
name: yurtappoverriders.apps.openyurt.io
spec:
group: apps.openyurt.io
names:
kind: YurtAppOverrider
listKind: YurtAppOverriderList
plural: yurtappoverriders
shortNames:
- yao
singular: yurtappoverrider
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: The subject kind of this overrider.
jsonPath: .subject.kind
name: Subject
type: string
- description: The subject name of this overrider.
jsonPath: .subject.name
name: Name
type: string
- description: CreationTimestamp is a timestamp representing the server time when
this object was created. It is not guaranteed to be set in happens-before
order across separate operations. Clients may not set this value. It is represented
in RFC3339 form and is in UTC.
jsonPath: .metadata.creationTimestamp
name: AGE
type: date
name: v1alpha1
schema:
openAPIV3Schema:
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
entries:
items:
description: Describe detailed multi-region configuration of the subject
Entry describe a set of nodepools and their shared or identical configurations
properties:
items:
items:
description: Item represents configuration to be injected. Only
one of its members may be specified.
properties:
image:
description: ImageItem specifies the corresponding container
and the claimed image
properties:
containerName:
description: ContainerName represents name of the container
in which the Image will be replaced
type: string
imageClaim:
description: ImageClaim represents the claimed image name
which is injected into the container above
type: string
required:
- containerName
- imageClaim
type: object
replicas:
format: int32
type: integer
type: object
type: array
patches:
description: Convert Patch struct into json patch operation
items:
properties:
operation:
description: Operation represents the operation
enum:
- add
- remove
- replace
type: string
path:
description: Path represents the path in the json patch
type: string
value:
description: Indicates the value of json patch
x-kubernetes-preserve-unknown-fields: true
required:
- operation
- path
type: object
type: array
pools:
items:
type: string
type: array
required:
- pools
type: object
type: array
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
subject:
description: Describe the object Entries belongs
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
name:
description: Name is the name of YurtAppSet or YurtAppDaemon
type: string
required:
- name
type: object
required:
- entries
- subject
type: object
served: true
storage: true
subresources: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
71 changes: 71 additions & 0 deletions charts/yurt-manager/templates/yurt-manager-auto-generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ rules:
- get
- patch
- update
- apiGroups:
- apps.openyurt.io
resources:
- yurtappoverriders
verbs:
- get
- list
- watch
- apiGroups:
- apps.openyurt.io
resources:
Expand Down Expand Up @@ -516,6 +524,26 @@ metadata:
creationTimestamp: null
name: yurt-manager-mutating-webhook-configuration
webhooks:
- admissionReviewVersions:
- v1
clientConfig:
service:
name: yurt-manager-webhook-service
namespace: {{ .Release.Namespace }}
path: /mutate-apps-v1-deployment
failurePolicy: Ignore
name: mutate.apps.v1.deployment
rules:
- apiGroups:
- apps
apiVersions:
- v1
operations:
- CREATE
- UPDATE
resources:
- deployments
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
Expand Down Expand Up @@ -618,6 +646,27 @@ webhooks:
resources:
- yurtappdaemons
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: yurt-manager-webhook-service
namespace: {{ .Release.Namespace }}
path: /mutate-apps-openyurt-io-v1alpha1-yurtappoverrider
failurePolicy: Fail
name: mutate.apps.v1alpha1.yurtappoverrider.openyurt.io
rules:
- apiGroups:
- apps.openyurt.io
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- yurtappoverriders
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
Expand Down Expand Up @@ -789,6 +838,28 @@ webhooks:
resources:
- yurtappdaemons
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: yurt-manager-webhook-service
namespace: {{ .Release.Namespace }}
path: /validate-apps-openyurt-io-v1alpha1-yurtappoverrider
failurePolicy: Fail
name: validate.apps.v1alpha1.yurtappoverrider.openyurt.io
rules:
- apiGroups:
- apps.openyurt.io
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
rambohe-ch marked this conversation as resolved.
Show resolved Hide resolved
- DELETE
resources:
- yurtappoverriders
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
Expand Down
36 changes: 21 additions & 15 deletions cmd/yurt-manager/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,28 @@ import (

// YurtManagerOptions is the main context object for the yurt-manager.
type YurtManagerOptions struct {
Generic *GenericOptions
NodePoolController *NodePoolControllerOptions
GatewayPickupController *GatewayPickupControllerOptions
YurtStaticSetController *YurtStaticSetControllerOptions
YurtAppSetController *YurtAppSetControllerOptions
YurtAppDaemonController *YurtAppDaemonControllerOptions
PlatformAdminController *PlatformAdminControllerOptions
Generic *GenericOptions
NodePoolController *NodePoolControllerOptions
GatewayPickupController *GatewayPickupControllerOptions
YurtStaticSetController *YurtStaticSetControllerOptions
YurtAppSetController *YurtAppSetControllerOptions
YurtAppDaemonController *YurtAppDaemonControllerOptions
PlatformAdminController *PlatformAdminControllerOptions
YurtAppOverriderController *YurtAppOverriderControllerOptions
}

// NewYurtManagerOptions creates a new YurtManagerOptions with a default config.
func NewYurtManagerOptions() (*YurtManagerOptions, error) {

s := YurtManagerOptions{
Generic: NewGenericOptions(),
NodePoolController: NewNodePoolControllerOptions(),
GatewayPickupController: NewGatewayPickupControllerOptions(),
YurtStaticSetController: NewYurtStaticSetControllerOptions(),
YurtAppSetController: NewYurtAppSetControllerOptions(),
YurtAppDaemonController: NewYurtAppDaemonControllerOptions(),
PlatformAdminController: NewPlatformAdminControllerOptions(),
Generic: NewGenericOptions(),
NodePoolController: NewNodePoolControllerOptions(),
GatewayPickupController: NewGatewayPickupControllerOptions(),
YurtStaticSetController: NewYurtStaticSetControllerOptions(),
YurtAppSetController: NewYurtAppSetControllerOptions(),
YurtAppDaemonController: NewYurtAppDaemonControllerOptions(),
PlatformAdminController: NewPlatformAdminControllerOptions(),
YurtAppOverriderController: NewYurtAppOverriderControllerOptions(),
}

return &s, nil
Expand All @@ -58,6 +60,7 @@ func (y *YurtManagerOptions) Flags(allControllers, disabledByDefaultControllers
y.YurtStaticSetController.AddFlags(fss.FlagSet("yurtstaticset controller"))
y.YurtAppDaemonController.AddFlags(fss.FlagSet("yurtappdaemon controller"))
y.PlatformAdminController.AddFlags(fss.FlagSet("iot controller"))
y.YurtAppOverriderController.AddFlags(fss.FlagSet("yurtappoverrider controller"))
// Please Add Other controller flags @kadisi

return fss
Expand All @@ -72,6 +75,7 @@ func (y *YurtManagerOptions) Validate(allControllers []string, controllerAliases
errs = append(errs, y.YurtStaticSetController.Validate()...)
errs = append(errs, y.YurtAppDaemonController.Validate()...)
errs = append(errs, y.PlatformAdminController.Validate()...)
errs = append(errs, y.YurtAppOverriderController.Validate()...)
return utilerrors.NewAggregate(errs)
}

Expand All @@ -92,10 +96,12 @@ func (y *YurtManagerOptions) ApplyTo(c *config.Config, controllerAliases map[str
if err := y.PlatformAdminController.ApplyTo(&c.ComponentConfig.PlatformAdminController); err != nil {
return err
}
if err := y.YurtAppOverriderController.ApplyTo(&c.ComponentConfig.YurtAppOverriderController); err != nil {
return err
}
if err := y.GatewayPickupController.ApplyTo(&c.ComponentConfig.GatewayPickupController); err != nil {
return err
}

return nil
}

Expand Down
60 changes: 60 additions & 0 deletions cmd/yurt-manager/app/options/yurtappoverridercontroller.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
Copyright 2023 The OpenYurt Authors.

Licensed under the Apache License, Version 2.0 (the License);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an AS IS BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package options

import (
"github.com/spf13/pflag"

"github.com/openyurtio/openyurt/pkg/yurtmanager/controller/yurtappoverrider/config"
)

type YurtAppOverriderControllerOptions struct {
*config.YurtAppOverriderControllerConfiguration
}

func NewYurtAppOverriderControllerOptions() *YurtAppOverriderControllerOptions {
return &YurtAppOverriderControllerOptions{
&config.YurtAppOverriderControllerConfiguration{},
}
}

// AddFlags adds flags related to nodepool for yurt-manager to the specified FlagSet.
func (n *YurtAppOverriderControllerOptions) AddFlags(fs *pflag.FlagSet) {
if n == nil {
return
}

//fs.BoolVar(&n.CreateDefaultPool, "create-default-pool", n.CreateDefaultPool, "Create default cloud/edge pools if indicated.")
}

// ApplyTo fills up nodepool config with options.
func (o *YurtAppOverriderControllerOptions) ApplyTo(cfg *config.YurtAppOverriderControllerConfiguration) error {
if o == nil {
return nil
}

return nil
}

// Validate checks validation of YurtAppOverriderControllerOptions.
func (o *YurtAppOverriderControllerOptions) Validate() []error {
if o == nil {
return nil
}
errs := []error{}
return errs
}
2 changes: 2 additions & 0 deletions cmd/yurt-manager/names/controller_names.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
ServiceTopologyEndpointSliceController = "service-topology-endpointslice-controller"
YurtAppSetController = "yurt-app-set-controller"
YurtAppDaemonController = "yurt-app-daemon-controller"
YurtAppOverriderController = "yurt-app-overrider-controller"
YurtStaticSetController = "yurt-static-set-controller"
YurtCoordinatorCertController = "yurt-coordinator-cert-controller"
DelegateLeaseController = "delegate-lease-controller"
Expand All @@ -47,6 +48,7 @@ func YurtManagerControllerAliases() map[string]string {
"yurtappset": YurtAppSetController,
"yurtappdaemon": YurtAppDaemonController,
"yurtstaticset": YurtStaticSetController,
"yurtappoverrider": YurtAppOverriderController,
"yurtcoordinatorcert": YurtCoordinatorCertController,
"delegatelease": DelegateLeaseController,
"podbinding": PodBindingController,
Expand Down
Loading