Skip to content

Commit

Permalink
🌱 add: annotation /is-poc
Browse files Browse the repository at this point in the history
  • Loading branch information
anngdinh committed Oct 14, 2024
1 parent 578a355 commit fac1728
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
7 changes: 7 additions & 0 deletions pkg/ingress/controller/annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -107,6 +108,7 @@ type IngressConfig struct {
CertificateIDs []string
EnableAutoscale bool
TargetType TargetType
IsPoc bool
}

func NewIngressConfig(pService *nwv1.Ingress) *IngressConfig {
Expand Down Expand Up @@ -141,6 +143,7 @@ func NewIngressConfig(pService *nwv1.Ingress) *IngressConfig {
CertificateIDs: []string{},
EnableAutoscale: false,
TargetType: TargetTypeInstance,
IsPoc: false,
}
if pService == nil {
return opt
Expand Down Expand Up @@ -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
}

Expand All @@ -310,6 +316,7 @@ func (s *IngressConfig) CreateLoadbalancerOptions() *loadbalancer.CreateOpts {
SubnetID: "",
Type: s.LoadBalancerType,
AutoScalable: s.EnableAutoscale,
IsPoc: s.IsPoc,
}
return opt
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/vngcloud/annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -107,6 +108,7 @@ type ServiceConfig struct {
EnableProxyProtocol []string
EnableAutoscale bool
TargetType TargetType
IsPoc bool
}

func NewServiceConfig(pService *corev1.Service) *ServiceConfig {
Expand Down Expand Up @@ -138,6 +140,7 @@ func NewServiceConfig(pService *corev1.Service) *ServiceConfig {
SecurityGroups: []string{},
EnableProxyProtocol: []string{},
EnableAutoscale: false,
IsPoc: false,
}
if pService == nil {
return opt
Expand Down Expand Up @@ -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
}

Expand All @@ -291,6 +297,7 @@ func (s *ServiceConfig) CreateLoadbalancerOptions() *loadbalancer.CreateOpts {
SubnetID: "",
Type: s.LoadBalancerType,
AutoScalable: s.EnableAutoscale,
IsPoc: s.IsPoc,
}
return opt
}
Expand Down

0 comments on commit fac1728

Please sign in to comment.