diff --git a/go.mod b/go.mod index 3f221a8..17f5179 100755 --- a/go.mod +++ b/go.mod @@ -7,11 +7,13 @@ toolchain go1.22.4 require ( github.com/cuongpiger/joat v1.0.9 github.com/mitchellh/go-homedir v1.1.0 + github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.18.2 - github.com/vngcloud/vngcloud-go-sdk v1.0.14-0.20240815093737-8907a96f9716 + github.com/stretchr/testify v1.9.0 + github.com/vngcloud/vngcloud-go-sdk v1.0.14-0.20241011061158-323134cc8f32 gopkg.in/gcfg.v1 v1.2.3 k8s.io/api v0.31.0 k8s.io/apimachinery v0.31.0 @@ -76,7 +78,7 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/onsi/ginkgo/v2 v2.19.0 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect - github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_golang v1.19.1 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.55.0 // indirect diff --git a/go.sum b/go.sum index 5e67e9e..e15e9b0 100755 --- a/go.sum +++ b/go.sum @@ -212,6 +212,8 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 h1:6fotK7 github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75/go.mod h1:KO6IkyS8Y3j8OdNO85qEYBsRPuteD+YciPomcXdrMnk= github.com/vngcloud/vngcloud-go-sdk v1.0.14-0.20240815093737-8907a96f9716 h1:ra119ks9SWEtIbwPUEr1+iyI5G6bd3vwIQx0yNaAO6U= github.com/vngcloud/vngcloud-go-sdk v1.0.14-0.20240815093737-8907a96f9716/go.mod h1:3ZjgN6oq5o7sYrShj2dOPOBF3cqWk6IW+/0VVpJWYf4= +github.com/vngcloud/vngcloud-go-sdk v1.0.14-0.20241011061158-323134cc8f32 h1:F3im+FQYDtl4K0xqLuloXCnV6mQP4nPLRfEeMqkFoDY= +github.com/vngcloud/vngcloud-go-sdk v1.0.14-0.20241011061158-323134cc8f32/go.mod h1:3ZjgN6oq5o7sYrShj2dOPOBF3cqWk6IW+/0VVpJWYf4= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= diff --git a/pkg/ingress/controller/annotation.go b/pkg/ingress/controller/annotation.go index cdba9ba..7be6c73 100644 --- a/pkg/ingress/controller/annotation.go +++ b/pkg/ingress/controller/annotation.go @@ -43,6 +43,7 @@ const ( ServiceAnnotationScheme = DEFAULT_K8S_SERVICE_ANNOTATION_PREFIX + "/scheme" ServiceAnnotationCertificateIDs = DEFAULT_K8S_SERVICE_ANNOTATION_PREFIX + "/certificate-ids" ServiceAnnotationEnableAutoscale = DEFAULT_K8S_SERVICE_ANNOTATION_PREFIX + "/enable-autoscale" + ServiceAnnotationIsPoc = DEFAULT_K8S_SERVICE_ANNOTATION_PREFIX + "/is-poc" // Listener annotations ServiceAnnotationIdleTimeoutClient = DEFAULT_K8S_SERVICE_ANNOTATION_PREFIX + "/idle-timeout-client" // both annotation and cloud-config @@ -107,6 +108,7 @@ type IngressConfig struct { CertificateIDs []string EnableAutoscale bool TargetType TargetType + IsPoc bool } func NewIngressConfig(pService *nwv1.Ingress) *IngressConfig { @@ -141,6 +143,7 @@ func NewIngressConfig(pService *nwv1.Ingress) *IngressConfig { CertificateIDs: []string{}, EnableAutoscale: false, TargetType: TargetTypeInstance, + IsPoc: false, } if pService == nil { return opt @@ -299,6 +302,9 @@ func NewIngressConfig(pService *nwv1.Ingress) *IngressConfig { klog.Warningf("Invalid annotation \"%s\" value, must be \"%s\" or \"%s\"", ServiceAnnotationTargetType, string(TargetTypeInstance), string(TargetTypeIP)) } } + if option, ok := pService.Annotations[ServiceAnnotationIsPoc]; ok { + opt.IsPoc = utils.ParseBoolAnnotation(option, ServiceAnnotationIsPoc, opt.IsPoc) + } return opt } @@ -310,6 +316,7 @@ func (s *IngressConfig) CreateLoadbalancerOptions() *loadbalancer.CreateOpts { SubnetID: "", Type: s.LoadBalancerType, AutoScalable: s.EnableAutoscale, + IsPoc: s.IsPoc, } return opt } diff --git a/pkg/vngcloud/annotation.go b/pkg/vngcloud/annotation.go index b87d34f..09850a8 100644 --- a/pkg/vngcloud/annotation.go +++ b/pkg/vngcloud/annotation.go @@ -44,6 +44,7 @@ const ( ServiceAnnotationTags = DEFAULT_K8S_SERVICE_ANNOTATION_PREFIX + "/tags" ServiceAnnotationScheme = DEFAULT_K8S_SERVICE_ANNOTATION_PREFIX + "/scheme" ServiceAnnotationEnableAutoscale = DEFAULT_K8S_SERVICE_ANNOTATION_PREFIX + "/enable-autoscale" + ServiceAnnotationIsPoc = DEFAULT_K8S_SERVICE_ANNOTATION_PREFIX + "/is-poc" // // Listener annotations ServiceAnnotationIdleTimeoutClient = DEFAULT_K8S_SERVICE_ANNOTATION_PREFIX + "/idle-timeout-client" // both annotation and cloud-config @@ -107,6 +108,7 @@ type ServiceConfig struct { EnableProxyProtocol []string EnableAutoscale bool TargetType TargetType + IsPoc bool } func NewServiceConfig(pService *corev1.Service) *ServiceConfig { @@ -138,6 +140,7 @@ func NewServiceConfig(pService *corev1.Service) *ServiceConfig { SecurityGroups: []string{}, EnableProxyProtocol: []string{}, EnableAutoscale: false, + IsPoc: false, } if pService == nil { return opt @@ -280,6 +283,9 @@ func NewServiceConfig(pService *corev1.Service) *ServiceConfig { klog.Warningf("Invalid annotation \"%s\" value, must be \"%s\" or \"%s\"", ServiceAnnotationTargetType, string(TargetTypeInstance), string(TargetTypeIP)) } } + if option, ok := pService.Annotations[ServiceAnnotationIsPoc]; ok { + opt.IsPoc = utils.ParseBoolAnnotation(option, ServiceAnnotationIsPoc, opt.IsPoc) + } return opt } @@ -291,6 +297,7 @@ func (s *ServiceConfig) CreateLoadbalancerOptions() *loadbalancer.CreateOpts { SubnetID: "", Type: s.LoadBalancerType, AutoScalable: s.EnableAutoscale, + IsPoc: s.IsPoc, } return opt }