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

move iot controller to yurt-manager #1488

Merged
merged 2 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8,493 changes: 8,493 additions & 0 deletions charts/yurt-manager/crds/iot.openyurt.io_platformadmins.yaml

Large diffs are not rendered by default.

88 changes: 88 additions & 0 deletions charts/yurt-manager/templates/yurt-manager-auto-generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,28 @@ rules:
- patch
- update
- watch
- apiGroups:
- ""
resources:
- configmaps
- services
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- configmaps/status
- services/status
verbs:
- get
- patch
- update
- apiGroups:
- ""
resources:
Expand Down Expand Up @@ -360,6 +382,32 @@ rules:
- list
- patch
- watch
- apiGroups:
- iot.openyurt.io
resources:
- platformadmins
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- iot.openyurt.io
resources:
- platformadmins/finalizers
verbs:
- update
- apiGroups:
- iot.openyurt.io
resources:
- platformadmins/status
verbs:
- get
- patch
- update
- apiGroups:
- raven.openyurt.io
resources:
Expand Down Expand Up @@ -430,6 +478,26 @@ webhooks:
resources:
- nodepools
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: yurt-manager-webhook-service
namespace: {{ .Release.Namespace }}
path: /mutate-iot-openyurt-io-v1alpha2-platformadmin
failurePolicy: Fail
name: mplatformadmin.kb.io
rules:
- apiGroups:
- iot.openyurt.io
apiVersions:
- v1alpha2
operations:
- CREATE
- UPDATE
resources:
- platformadmins
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
Expand Down Expand Up @@ -541,6 +609,26 @@ webhooks:
resources:
- nodepools
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: yurt-manager-webhook-service
namespace: {{ .Release.Namespace }}
path: /validate-iot-openyurt-io-v1alpha2-platformadmin
failurePolicy: Fail
name: vplatformadmin.kb.io
rules:
- apiGroups:
- iot.openyurt.io
apiVersions:
- v1alpha2
operations:
- CREATE
- UPDATE
resources:
- platformadmins
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
Expand Down
7 changes: 7 additions & 0 deletions cmd/yurt-manager/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type YurtManagerOptions struct {
YurtStaticSetController *YurtStaticSetControllerOptions
YurtAppSetController *YurtAppSetControllerOptions
YurtAppDaemonController *YurtAppDaemonControllerOptions
PlatformAdminController *PlatformAdminControllerOptions
}

// NewYurtManagerOptions creates a new YurtManagerOptions with a default config.
Expand All @@ -43,6 +44,7 @@ func NewYurtManagerOptions() (*YurtManagerOptions, error) {
YurtStaticSetController: NewYurtStaticSetControllerOptions(),
YurtAppSetController: NewYurtAppSetControllerOptions(),
YurtAppDaemonController: NewYurtAppDaemonControllerOptions(),
PlatformAdminController: NewPlatformAdminControllerOptions(),
}

return &s, nil
Expand All @@ -55,6 +57,7 @@ func (y *YurtManagerOptions) Flags() cliflag.NamedFlagSets {
y.GatewayController.AddFlags(fss.FlagSet("gateway controller"))
y.YurtStaticSetController.AddFlags(fss.FlagSet("yurtstaticset controller"))
y.YurtAppDaemonController.AddFlags(fss.FlagSet("yurtappdaemon controller"))
y.PlatformAdminController.AddFlags(fss.FlagSet("iot controller"))
// Please Add Other controller flags @kadisi

return fss
Expand All @@ -68,6 +71,7 @@ func (y *YurtManagerOptions) Validate() error {
errs = append(errs, y.GatewayController.Validate()...)
errs = append(errs, y.YurtStaticSetController.Validate()...)
errs = append(errs, y.YurtAppDaemonController.Validate()...)
errs = append(errs, y.PlatformAdminController.Validate()...)
return utilerrors.NewAggregate(errs)
}

Expand All @@ -85,6 +89,9 @@ func (y *YurtManagerOptions) ApplyTo(c *config.Config) error {
if err := y.YurtAppDaemonController.ApplyTo(&c.ComponentConfig.YurtAppDaemonController); err != nil {
return err
}
if err := y.PlatformAdminController.ApplyTo(&c.ComponentConfig.PlatformAdminController); err != nil {
return err
}
return nil
}

Expand Down
63 changes: 63 additions & 0 deletions cmd/yurt-manager/app/options/platformadmincontroller.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
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 (
"errors"

"github.com/spf13/pflag"

"github.com/openyurtio/openyurt/pkg/controller/platformadmin/config"
)

type PlatformAdminControllerOptions struct {
*config.PlatformAdminControllerConfiguration
}

func NewPlatformAdminControllerOptions() *PlatformAdminControllerOptions {
return &PlatformAdminControllerOptions{
config.NewPlatformAdminControllerConfiguration(),
}
}

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

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

// Validate checks validation of IoTControllerOptions.
func (o *PlatformAdminControllerOptions) Validate() []error {
if o == nil {
return nil
}
errs := []error{}
if o.PlatformAdminControllerConfiguration == nil {
errs = append(errs, errors.New("IoTControllerConfiguration can not be empty!"))
}
return errs
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ require (
google.golang.org/grpc v1.55.0
gopkg.in/cheggaaa/pb.v1 v1.0.28
gopkg.in/square/go-jose.v2 v2.6.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.22.3
k8s.io/apimachinery v0.22.3
k8s.io/apiserver v0.22.3
Expand Down Expand Up @@ -153,7 +154,6 @@ require (
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.22.2 // indirect
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.22 // indirect
Expand Down
26 changes: 26 additions & 0 deletions pkg/apis/addtoscheme_iot_v1alpha1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
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 apis

import (
version "github.com/openyurtio/openyurt/pkg/apis/iot/v1alpha1"
)

func init() {
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
AddToSchemes = append(AddToSchemes, version.SchemeBuilder.AddToScheme)
}
26 changes: 26 additions & 0 deletions pkg/apis/addtoscheme_iot_v1alpha2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
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 apis

import (
version "github.com/openyurtio/openyurt/pkg/apis/iot/v1alpha2"
)

func init() {
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
AddToSchemes = append(AddToSchemes, version.SchemeBuilder.AddToScheme)
}
38 changes: 38 additions & 0 deletions pkg/apis/iot/v1alpha1/condition_const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
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 v1alpha1

const (
// ConfigmapAvailableCondition documents the status of the PlatformAdmin configmap.
ConfigmapAvailableCondition PlatformAdminConditionType = "ConfigmapAvailable"

ConfigmapProvisioningReason = "ConfigmapProvisioning"

ConfigmapProvisioningFailedReason = "ConfigmapProvisioningFailed"
// ServiceAvailableCondition documents the status of the PlatformAdmin service.
ServiceAvailableCondition PlatformAdminConditionType = "ServiceAvailable"

ServiceProvisioningReason = "ServiceProvisioning"

ServiceProvisioningFailedReason = "ServiceProvisioningFailed"
// DeploymentAvailableCondition documents the status of the PlatformAdmin deployment.
DeploymentAvailableCondition PlatformAdminConditionType = "DeploymentAvailable"

DeploymentProvisioningReason = "DeploymentProvisioning"

DeploymentProvisioningFailedReason = "DeploymentProvisioningFailed"
)
24 changes: 24 additions & 0 deletions pkg/apis/iot/v1alpha1/default.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
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 v1alpha1

// SetDefaultsPlatformAdmin set default values for PlatformAdmin.
func SetDefaultsPlatformAdmin(obj *PlatformAdmin) {
if obj.Annotations == nil {
obj.Annotations = make(map[string]string)
}
}
17 changes: 17 additions & 0 deletions pkg/apis/iot/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
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.
*/
// +groupName=iot.openyurt.io
package v1alpha1
Loading