fix:modify the default resource reservation of gateway system, gateway.go typo
This commit is contained in:
2
Makefile
2
Makefile
@@ -7,7 +7,7 @@
|
||||
CRD_OPTIONS ?= "crd:trivialVersions=true"
|
||||
|
||||
GV="network:v1alpha1 servicemesh:v1alpha2 tenant:v1alpha1 tenant:v1alpha2 devops:v1alpha1 iam:v1alpha2 devops:v1alpha3 cluster:v1alpha1 storage:v1alpha1 auditing:v1alpha1 types:v1beta1 quota:v1alpha2 application:v1alpha1 notification:v2beta1 gateway:v1alpha1"
|
||||
MANIFESTS="application/* cluster/* iam/* network/v1alpha1 quota/* storage/* tenant/*"
|
||||
MANIFESTS="application/* cluster/* iam/* network/v1alpha1 quota/* storage/* tenant/* gateway/*"
|
||||
|
||||
# App Version
|
||||
APP_VERSION = v3.2.0
|
||||
|
||||
27
config/crds/gateway.kubesphere.io_gateways.yaml
generated
27
config/crds/gateway.kubesphere.io_gateways.yaml
generated
@@ -66,6 +66,33 @@ spec:
|
||||
replicas:
|
||||
format: int32
|
||||
type: integer
|
||||
resources:
|
||||
description: ResourceRequirements describes the compute resource
|
||||
requirements.
|
||||
properties:
|
||||
limits:
|
||||
additionalProperties:
|
||||
anyOf:
|
||||
- type: integer
|
||||
- type: string
|
||||
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
|
||||
x-kubernetes-int-or-string: true
|
||||
description: 'Limits describes the maximum amount of compute
|
||||
resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
|
||||
type: object
|
||||
requests:
|
||||
additionalProperties:
|
||||
anyOf:
|
||||
- type: integer
|
||||
- type: string
|
||||
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
|
||||
x-kubernetes-int-or-string: true
|
||||
description: 'Requests describes the minimum amount of compute
|
||||
resources required. If Requests is omitted for a container,
|
||||
it defaults to Limits if that is explicitly specified, otherwise
|
||||
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
|
||||
type: object
|
||||
type: object
|
||||
type: object
|
||||
service:
|
||||
properties:
|
||||
|
||||
@@ -192,13 +192,7 @@ spec:
|
||||
# ref: https://github.com/kubernetes/ingress-nginx/issues/4735#issuecomment-551204903
|
||||
# Ideally, there should be no limits.
|
||||
# https://engineering.indeedblog.com/blog/2019/12/cpu-throttling-regression-fix/
|
||||
resources:
|
||||
# limits:
|
||||
# cpu: 100m
|
||||
# memory: 90Mi
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 90Mi
|
||||
resources: {{ toYaml .Values.deployment.resources | nindent 6 }}
|
||||
|
||||
# Mutually exclusive with keda autoscaling
|
||||
autoscaling:
|
||||
|
||||
@@ -26,4 +26,12 @@ service:
|
||||
deployment:
|
||||
annotations: {}
|
||||
replicas: 1
|
||||
resources:
|
||||
# limits:
|
||||
# cpu: 100m
|
||||
# memory: 90Mi
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 90Mi
|
||||
|
||||
|
||||
@@ -93,9 +93,9 @@ func (c *gatewayOperator) getWorkingNamespace(namespace string) string {
|
||||
return ns
|
||||
}
|
||||
|
||||
// overide user's setting when create/update a project gateway.
|
||||
func (c *gatewayOperator) overideDefaultValue(gateway *v1alpha1.Gateway, namespace string) *v1alpha1.Gateway {
|
||||
// overide default name
|
||||
// override user's setting when create/update a project gateway.
|
||||
func (c *gatewayOperator) overrideDefaultValue(gateway *v1alpha1.Gateway, namespace string) *v1alpha1.Gateway {
|
||||
// override default name
|
||||
gateway.Name = fmt.Sprint(gatewayPrefix, namespace)
|
||||
if gateway.Name != globalGatewayname {
|
||||
gateway.Spec.Controller.Scope = v1alpha1.Scope{Enabled: true, Namespace: namespace}
|
||||
@@ -174,6 +174,9 @@ func (c *gatewayOperator) convert(namespace string, svc *corev1.Service, deploy
|
||||
legacy.Spec.Deployment.Annotations = make(map[string]string)
|
||||
legacy.Spec.Deployment.Annotations[SidecarInject] = an
|
||||
}
|
||||
if len(deploy.Spec.Template.Spec.Containers) > 0 {
|
||||
legacy.Spec.Deployment.Resources = deploy.Spec.Template.Spec.Containers[0].Resources
|
||||
}
|
||||
return &legacy
|
||||
}
|
||||
|
||||
@@ -201,7 +204,7 @@ func (c *gatewayOperator) getMasterNodeIp() []string {
|
||||
}
|
||||
|
||||
func (c *gatewayOperator) updateStatus(gateway *v1alpha1.Gateway, svc *corev1.Service) (*v1alpha1.Gateway, error) {
|
||||
// append selected node ip as loadbalancer ingress ip
|
||||
// append selected node ip as loadBalancer ingress ip
|
||||
if svc.Spec.Type != corev1.ServiceTypeLoadBalancer && len(svc.Status.LoadBalancer.Ingress) == 0 {
|
||||
rips := c.getMasterNodeIp()
|
||||
for _, rip := range rips {
|
||||
@@ -240,8 +243,8 @@ func (c *gatewayOperator) updateStatus(gateway *v1alpha1.Gateway, svc *corev1.Se
|
||||
return gateway, nil
|
||||
}
|
||||
|
||||
// GetGateways returns all Gateways from the project. There are at most 2 gatways exists in a project,
|
||||
// a Glabal Gateway and a Project Gateway or a Legacy Project Gateway.
|
||||
// GetGateways returns all Gateways from the project. There are at most 2 gateways exists in a project,
|
||||
// a Global Gateway and a Project Gateway or a Legacy Project Gateway.
|
||||
func (c *gatewayOperator) GetGateways(namespace string) ([]*v1alpha1.Gateway, error) {
|
||||
|
||||
var gateways []*v1alpha1.Gateway
|
||||
@@ -295,7 +298,7 @@ func (c *gatewayOperator) CreateGateway(namespace string, obj *v1alpha1.Gateway)
|
||||
return nil, fmt.Errorf("can't create project gateway if legacy gateway exists, please upgrade the gateway firstly")
|
||||
}
|
||||
|
||||
c.overideDefaultValue(obj, namespace)
|
||||
c.overrideDefaultValue(obj, namespace)
|
||||
err := c.client.Create(context.TODO(), obj)
|
||||
return obj, err
|
||||
}
|
||||
@@ -316,7 +319,7 @@ func (c *gatewayOperator) UpdateGateway(namespace string, obj *v1alpha1.Gateway)
|
||||
if c.options.Namespace == "" && obj.Namespace != namespace || c.options.Namespace != "" && c.options.Namespace != obj.Namespace {
|
||||
return nil, fmt.Errorf("namepsace doesn't match with origin namesapce")
|
||||
}
|
||||
c.overideDefaultValue(obj, namespace)
|
||||
c.overrideDefaultValue(obj, namespace)
|
||||
err := c.client.Update(context.TODO(), obj)
|
||||
return obj, err
|
||||
}
|
||||
@@ -332,7 +335,7 @@ func (c *gatewayOperator) UpgradeGateway(namespace string) (*v1alpha1.Gateway, e
|
||||
return nil, fmt.Errorf("invalid operation, can't upgrade legacy gateway when working namespace changed")
|
||||
}
|
||||
|
||||
// Get legency gateway's config from configmap
|
||||
// Get legacy gateway's config from configmap
|
||||
cm := &corev1.ConfigMap{}
|
||||
err := c.client.Get(context.TODO(), client.ObjectKey{Namespace: l.Namespace, Name: fmt.Sprintf("%s-nginx", l.Name)}, cm)
|
||||
if err == nil {
|
||||
@@ -355,7 +358,7 @@ func (c *gatewayOperator) UpgradeGateway(namespace string) (*v1alpha1.Gateway, e
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Patch the legacy Serivce with helm annotations, So that it can be mannaged by the helm release.
|
||||
// Patch the legacy Service with helm annotations, So that it can be managed by the helm release.
|
||||
patch := []byte(fmt.Sprintf(helmPatch, l.Name, l.Namespace))
|
||||
err = c.client.Patch(context.Background(), &corev1.Service{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
@@ -368,7 +371,7 @@ func (c *gatewayOperator) UpgradeGateway(namespace string) (*v1alpha1.Gateway, e
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c.overideDefaultValue(l, namespace)
|
||||
c.overrideDefaultValue(l, namespace)
|
||||
err = c.client.Create(context.TODO(), l)
|
||||
return l, err
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ type GatewaySpec struct {
|
||||
|
||||
type ControllerSpec struct {
|
||||
// +optional
|
||||
Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
|
||||
Replicas *int32 `json:"replicas,omitempty"`
|
||||
// +optional
|
||||
Annotations map[string]string `json:"annotations,omitempty"`
|
||||
// +optional
|
||||
@@ -49,9 +49,11 @@ type ServiceSpec struct {
|
||||
|
||||
type DeploymentSpec struct {
|
||||
// +optional
|
||||
Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
|
||||
Replicas *int32 `json:"replicas,omitempty"`
|
||||
// +optional
|
||||
Annotations map[string]string `json:"annotations,omitempty"`
|
||||
// +optional
|
||||
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
|
||||
}
|
||||
|
||||
type Scope struct {
|
||||
|
||||
@@ -40,6 +40,13 @@ func (in *ControllerSpec) DeepCopyInto(out *ControllerSpec) {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.Config != nil {
|
||||
in, out := &in.Config, &out.Config
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
out.Scope = in.Scope
|
||||
}
|
||||
|
||||
@@ -68,6 +75,7 @@ func (in *DeploymentSpec) DeepCopyInto(out *DeploymentSpec) {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
in.Resources.DeepCopyInto(&out.Resources)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentSpec.
|
||||
|
||||
Reference in New Issue
Block a user