fix:modify the default resource reservation of gateway system, gateway.go typo
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user