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

AV-219160 : HTTP/2 support for AKO - Backend #1548

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
istio.io/api v0.0.0-20210512213424-c42041d3366d // indirect
istio.io/gogo-genproto v0.0.0-20210113155706-4daf5697332f // indirect
k8s.io/code-generator v0.28.3 // indirect
k8s.io/component-base v0.28.3 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
79 changes: 79 additions & 0 deletions go.sum

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions helm/ako/crds/ako.vmware.com_httprules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ spec:
required:
- type
type: object
enableHTTP2:
type: boolean
required:
- target
type: object
Expand Down
4 changes: 4 additions & 0 deletions internal/nodes/avi_model_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,7 @@ type AviPoolCommonFields struct {
PkiProfileRef *string
SslProfileRef *string
SslKeyAndCertificateRef *string
EnableHttp2 *bool
}

func (v *AviPoolNode) GetCheckSum() uint32 {
Expand Down Expand Up @@ -1682,6 +1683,9 @@ func (v *AviPoolNode) CalculateCheckSum() {
checksumStringSlice = append(checksumStringSlice, utils.Stringify(v.ServiceMetadata.HostNames))
}

if v.EnableHttp2 != nil {
checksumStringSlice = append(checksumStringSlice, utils.Stringify(*v.EnableHttp2))
}
chksumStr := fmt.Sprint(strings.Join(checksumStringSlice, delim))

checksum := utils.Hash(chksumStr)
Expand Down
4 changes: 4 additions & 0 deletions internal/nodes/crd_translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ func BuildPoolHTTPRule(host, poolPath, ingName, namespace, infraSettingName, key
pool.HealthMonitorRefs = pathHMs
pool.ApplicationPersistenceProfileRef = persistenceProfile

if httpRulePath.EnableHttp2 != nil {
pool.EnableHttp2 = httpRulePath.EnableHttp2
}

// from this path, generate refs to this pool node
if httpRulePath.LoadBalancerPolicy.Algorithm != "" {
pool.LbAlgorithm = proto.String(httpRulePath.LoadBalancerPolicy.Algorithm)
Expand Down
4 changes: 4 additions & 0 deletions internal/rest/avi_obj_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ func (rest *RestOperations) AviPoolBuild(pool_meta *nodes.AviPoolNode, cache_obj
pool.ApplicationPersistenceProfileRef = pool_meta.ApplicationPersistenceProfileRef
}

if pool_meta.EnableHttp2 != nil {
pool.EnableHttp2 = pool_meta.EnableHttp2
}

for i, server := range pool_meta.Servers {
port := pool_meta.Port
sip := server.Ip
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/ako/v1beta1/httprule.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type HTTPRulePaths struct {
TLS HTTPRuleTLS `json:"tls,omitempty"`
HealthMonitors []string `json:"healthMonitors,omitempty"`
ApplicationPersistence string `json:"applicationPersistence,omitempty"`
EnableHttp2 *bool `json:"enableHTTP2,omitempty"`
}

// HTTPRuleLBPolicy holds a path/pool's load balancer policies
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/ako/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions tests/dedicatedevhtests/l7_evh_crd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1369,3 +1369,78 @@ func TestHostRuleRegexAppRootInsecure(t *testing.T) {

TearDownIngressForCacheSyncCheckPath(t, modelName)
}

func TestHTTPRuleCreateDeleteWithEnableHTTP2ForEvh(t *testing.T) {
g := gomega.NewGomegaWithT(t)

modelName, _ := GetDedicatedModel("foo.com", "default")
rrName := "samplerr-foo"

SetupDomain()
secretName := "my-secret"
ingressName := "foo-with-targets"
svcName := "avisvc"

SetUpTestForIngress(t, svcName, modelName)
integrationtest.AddSecret(secretName, "default", "tlsCert", "tlsKey")
integrationtest.PollForCompletion(t, modelName, 5)
ingressObject := integrationtest.FakeIngress{
Name: ingressName,
Namespace: "default",
DnsNames: []string{"foo.com"},
Ips: []string{"8.8.8.8"},
HostNames: []string{"v1"},
Paths: []string{"/foo", "/bar"},
ServiceName: svcName,
TlsSecretDNS: map[string][]string{
secretName: {"foo.com"},
},
}

ingrFake := ingressObject.Ingress(true)
if _, err := KubeClient.NetworkingV1().Ingresses("default").Create(context.TODO(), ingrFake, metav1.CreateOptions{}); err != nil {
t.Fatalf("error in adding Ingress: %v", err)
}
integrationtest.PollForCompletion(t, modelName, 5)

poolFooKey := cache.NamespaceName{Namespace: "admin", Name: lib.Encode("cluster--default-foo.com_foo-"+ingressName+"-"+svcName, lib.Pool)}
poolBarKey := cache.NamespaceName{Namespace: "admin", Name: lib.Encode("cluster--default-foo.com_bar-"+ingressName+"-"+svcName, lib.Pool)}
httpRulePath := "/"
httprule := integrationtest.FakeHTTPRule{
Name: rrName,
Namespace: "default",
Fqdn: "foo.com",
PathProperties: []integrationtest.FakeHTTPRulePath{{
Path: httpRulePath,
EnableHTTP2: true,
}},
}

rrCreate := httprule.HTTPRule()
if _, err := lib.AKOControlConfig().V1beta1CRDClientset().AkoV1beta1().HTTPRules("default").Create(context.TODO(), rrCreate, metav1.CreateOptions{}); err != nil {
t.Fatalf("error in adding HTTPRule: %v", err)
}

integrationtest.VerifyMetadataHTTPRule(t, g, poolFooKey, "default/"+rrName+"/"+httpRulePath, true)
integrationtest.VerifyMetadataHTTPRule(t, g, poolBarKey, "default/"+rrName+"/"+httpRulePath, true)
_, aviModel := objects.SharedAviGraphLister().Get(modelName)
nodes := aviModel.(*avinodes.AviObjectGraph).GetAviEvhVS()

var evhNode *avinodes.AviEvhVsNode
if *isVipPerNS == "true" {
evhNode = nodes[0].EvhNodes[0]
} else {
evhNode = nodes[0]
}

g.Expect(*evhNode.PoolRefs[0].EnableHttp2).Should(gomega.Equal(true))

// delete httprule disables HTTP2
integrationtest.TeardownHTTPRule(t, rrName)
integrationtest.VerifyMetadataHTTPRule(t, g, poolFooKey, "default/"+rrName+"/"+httpRulePath, false)
integrationtest.VerifyMetadataHTTPRule(t, g, poolBarKey, "default/"+rrName+"/"+httpRulePath, false)

g.Expect(evhNode.PoolRefs[0].EnableHttp2).To(gomega.BeNil())

TearDownIngressForCacheSyncCheck(t, modelName)
}
68 changes: 68 additions & 0 deletions tests/dedicatedvstests/l7_dedicated_crd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,3 +765,71 @@ func TestHostRuleRegexAppRoot(t *testing.T) {

TearDownIngressForCacheSyncCheckPath(t, secretName, ingressName, modelName)
}

func TestHTTPRuleCreateDeleteEnableHTTP2(t *testing.T) {
g := gomega.NewGomegaWithT(t)

modelName := "admin/cluster--foo.com-L7-dedicated"
svcName := "avisvc"
rrname := "samplerr-foo"
secretName := "my-secret"
ingName := "foo-with-targets"

SetupDomain()
SetUpTestForIngress(t, svcName, modelName)
integrationtest.AddSecret(secretName, "default", "tlsCert", "tlsKey")
integrationtest.PollForCompletion(t, modelName, 5)
ingressObject := integrationtest.FakeIngress{
Name: ingName,
Namespace: "default",
DnsNames: []string{"foo.com"},
Ips: []string{"8.8.8.8"},
HostNames: []string{"v1"},
Paths: []string{"/foo", "/bar"},
ServiceName: svcName,
TlsSecretDNS: map[string][]string{
secretName: {"foo.com"},
},
}

ingrFake := ingressObject.Ingress(true)
if _, err := KubeClient.NetworkingV1().Ingresses("default").Create(context.TODO(), ingrFake, metav1.CreateOptions{}); err != nil {
t.Fatalf("error in adding Ingress: %v", err)
}
integrationtest.PollForCompletion(t, modelName, 5)

poolFooKey := cache.NamespaceName{Namespace: "admin", Name: "cluster--default-foo.com_foo-" + ingName}
poolBarKey := cache.NamespaceName{Namespace: "admin", Name: "cluster--default-foo.com_bar-" + ingName}

httpRulePath := "/"
httprule := integrationtest.FakeHTTPRule{
Name: rrname,
Namespace: "default",
Fqdn: "foo.com",
PathProperties: []integrationtest.FakeHTTPRulePath{{
Path: httpRulePath,
EnableHTTP2: true,
}},
}

rrCreate := httprule.HTTPRule()
if _, err := lib.AKOControlConfig().V1beta1CRDClientset().AkoV1beta1().HTTPRules("default").Create(context.TODO(), rrCreate, metav1.CreateOptions{}); err != nil {
t.Fatalf("error in adding HTTPRule: %v", err)
}

integrationtest.VerifyMetadataHTTPRule(t, g, poolFooKey, "default/"+rrname+"/"+httpRulePath, true)
integrationtest.VerifyMetadataHTTPRule(t, g, poolBarKey, "default/"+rrname+"/"+httpRulePath, true)
_, aviModel := objects.SharedAviGraphLister().Get(modelName)
nodes := aviModel.(*avinodes.AviObjectGraph).GetAviVS()
g.Expect(*nodes[0].PoolRefs[0].EnableHttp2).To(gomega.Equal(true))

// delete httprule disables HTTP2
integrationtest.TeardownHTTPRule(t, rrname)
integrationtest.VerifyMetadataHTTPRule(t, g, poolFooKey, "default/"+rrname+"/"+httpRulePath, false)
integrationtest.VerifyMetadataHTTPRule(t, g, poolBarKey, "default/"+rrname+"/"+httpRulePath, false)
_, aviModel = objects.SharedAviGraphLister().Get(modelName)
nodes = aviModel.(*avinodes.AviObjectGraph).GetAviVS()
g.Expect(nodes[0].PoolRefs[0].EnableHttp2).To(gomega.BeNil())

TearDownIngressForCacheSyncCheck(t, secretName, ingName, modelName)
}
67 changes: 67 additions & 0 deletions tests/evhtests/l7_evh_crd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1463,6 +1463,73 @@ func TestHTTPRuleWithInvalidPath(t *testing.T) {
TearDownIngressForCacheSyncCheck(t, secretName, ingressName, svcName, modelName)
}

func TestHTTPRuleCreateDeleteWithEnableHTTP2ForEvh(t *testing.T) {
g := gomega.NewGomegaWithT(t)

modelName, _ := GetModelName("foo.com", "default")
rrName := objNameMap.GenerateName("samplerr-foo")

SetupDomain()
secretName := objNameMap.GenerateName("my-secret")
ingressName := objNameMap.GenerateName("foo-with-targets")
svcName := objNameMap.GenerateName("avisvc")
SetUpTestForIngress(t, svcName, modelName)
integrationtest.AddSecret(secretName, "default", "tlsCert", "tlsKey")
integrationtest.PollForCompletion(t, modelName, 5)
ingressObject := integrationtest.FakeIngress{
Name: ingressName,
Namespace: "default",
DnsNames: []string{"foo.com"},
Ips: []string{"8.8.8.8"},
HostNames: []string{"v1"},
Paths: []string{"/foo", "/bar"},
ServiceName: svcName,
TlsSecretDNS: map[string][]string{
secretName: {"foo.com"},
},
}

ingrFake := ingressObject.Ingress(true)
if _, err := KubeClient.NetworkingV1().Ingresses("default").Create(context.TODO(), ingrFake, metav1.CreateOptions{}); err != nil {
t.Fatalf("error in adding Ingress: %v", err)
}
integrationtest.PollForCompletion(t, modelName, 5)

poolFooKey := cache.NamespaceName{Namespace: "admin", Name: lib.Encode("cluster--default-foo.com_foo-"+ingressName+"-"+svcName, lib.Pool)}
poolBarKey := cache.NamespaceName{Namespace: "admin", Name: lib.Encode("cluster--default-foo.com_bar-"+ingressName+"-"+svcName, lib.Pool)}
httpRulePath := "/"
httprule := integrationtest.FakeHTTPRule{
Name: rrName,
Namespace: "default",
Fqdn: "foo.com",
PathProperties: []integrationtest.FakeHTTPRulePath{{
Path: httpRulePath,
EnableHTTP2: true,
}},
}

rrCreate := httprule.HTTPRule()
if _, err := lib.AKOControlConfig().V1beta1CRDClientset().AkoV1beta1().HTTPRules("default").Create(context.TODO(), rrCreate, metav1.CreateOptions{}); err != nil {
t.Fatalf("error in adding HTTPRule: %v", err)
}

integrationtest.VerifyMetadataHTTPRule(t, g, poolFooKey, "default/"+rrName+"/"+httpRulePath, true)
integrationtest.VerifyMetadataHTTPRule(t, g, poolBarKey, "default/"+rrName+"/"+httpRulePath, true)
_, aviModel := objects.SharedAviGraphLister().Get(modelName)
nodes := aviModel.(*avinodes.AviObjectGraph).GetAviEvhVS()
g.Expect(*nodes[0].EvhNodes[0].PoolRefs[0].EnableHttp2).To(gomega.Equal(true))

// delete httprule disables HTTP2
integrationtest.TeardownHTTPRule(t, rrName)
integrationtest.VerifyMetadataHTTPRule(t, g, poolFooKey, "default/"+rrName+"/"+httpRulePath, false)
integrationtest.VerifyMetadataHTTPRule(t, g, poolBarKey, "default/"+rrName+"/"+httpRulePath, false)
_, aviModel = objects.SharedAviGraphLister().Get(modelName)
nodes = aviModel.(*avinodes.AviObjectGraph).GetAviEvhVS()
g.Expect(nodes[0].EvhNodes[0].PoolRefs[0].EnableHttp2).To(gomega.BeNil())

TearDownIngressForCacheSyncCheck(t, secretName, ingressName, svcName, modelName)
}

func TestCreateUpdateDeleteSSORuleForEvh(t *testing.T) {
g := gomega.NewGomegaWithT(t)

Expand Down
69 changes: 69 additions & 0 deletions tests/ingresstests/crd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,75 @@ func TestHTTPRuleWithInvalidPath(t *testing.T) {
TearDownIngressForCacheSyncCheck(t, ingName, svcName, secretName, modelName)
}

func TestHTTPRuleCreateDeleteEnableHTTP2(t *testing.T) {

g := gomega.NewGomegaWithT(t)

modelName := MODEL_NAME_PREFIX + "0"
svcName := objNameMap.GenerateName("avisvc")
rrname := objNameMap.GenerateName("samplerr-foo")
secretName := objNameMap.GenerateName("my-secret")
ingName := objNameMap.GenerateName("foo-with-targets")

SetupDomain()
SetUpTestForIngress(t, svcName, modelName)
integrationtest.AddSecret(secretName, "default", "tlsCert", "tlsKey")
integrationtest.PollForCompletion(t, modelName, 5)
ingressObject := integrationtest.FakeIngress{
Name: ingName,
Namespace: "default",
DnsNames: []string{"foo.com"},
Ips: []string{"8.8.8.8"},
HostNames: []string{"v1"},
Paths: []string{"/foo", "/bar"},
ServiceName: svcName,
TlsSecretDNS: map[string][]string{
secretName: {"foo.com"},
},
}

ingrFake := ingressObject.Ingress(true)
if _, err := KubeClient.NetworkingV1().Ingresses("default").Create(context.TODO(), ingrFake, metav1.CreateOptions{}); err != nil {
t.Fatalf("error in adding Ingress: %v", err)
}
integrationtest.PollForCompletion(t, modelName, 5)

poolFooKey := cache.NamespaceName{Namespace: "admin", Name: "cluster--default-foo.com_foo-" + ingName}
poolBarKey := cache.NamespaceName{Namespace: "admin", Name: "cluster--default-foo.com_bar-" + ingName}

httpRulePath := "/"
httprule := integrationtest.FakeHTTPRule{
Name: rrname,
Namespace: "default",
Fqdn: "foo.com",
PathProperties: []integrationtest.FakeHTTPRulePath{{
Path: httpRulePath,
EnableHTTP2: true,
}},
}

rrCreate := httprule.HTTPRule()
if _, err := lib.AKOControlConfig().V1beta1CRDClientset().AkoV1beta1().HTTPRules("default").Create(context.TODO(), rrCreate, metav1.CreateOptions{}); err != nil {
t.Fatalf("error in adding HTTPRule: %v", err)
}

integrationtest.VerifyMetadataHTTPRule(t, g, poolFooKey, "default/"+rrname+"/"+httpRulePath, true)
integrationtest.VerifyMetadataHTTPRule(t, g, poolBarKey, "default/"+rrname+"/"+httpRulePath, true)
_, aviModel := objects.SharedAviGraphLister().Get(modelName)
nodes := aviModel.(*avinodes.AviObjectGraph).GetAviVS()
g.Expect(*nodes[0].SniNodes[0].PoolRefs[0].EnableHttp2).To(gomega.Equal(true))

// delete httprule disables HTTP2
integrationtest.TeardownHTTPRule(t, rrname)
integrationtest.VerifyMetadataHTTPRule(t, g, poolFooKey, "default/"+rrname+"/"+httpRulePath, false)
integrationtest.VerifyMetadataHTTPRule(t, g, poolBarKey, "default/"+rrname+"/"+httpRulePath, false)
_, aviModel = objects.SharedAviGraphLister().Get(modelName)
nodes = aviModel.(*avinodes.AviObjectGraph).GetAviVS()
g.Expect(nodes[0].SniNodes[0].PoolRefs[0].EnableHttp2).To(gomega.BeNil())

TearDownIngressForCacheSyncCheck(t, ingName, svcName, secretName, modelName)
}

func TestHostRuleUseRegex(t *testing.T) {
g := gomega.NewGomegaWithT(t)

Expand Down
2 changes: 2 additions & 0 deletions tests/integrationtest/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -1886,6 +1886,7 @@ type FakeHTTPRulePath struct {
HealthMonitors []string
LbAlgorithm string
Hash string
EnableHTTP2 bool
}

func (rr FakeHTTPRule) HTTPRule() *akov1beta1.HTTPRule {
Expand All @@ -1902,6 +1903,7 @@ func (rr FakeHTTPRule) HTTPRule() *akov1beta1.HTTPRule {
Algorithm: p.LbAlgorithm,
Hash: p.Hash,
},
EnableHttp2: &p.EnableHTTP2,
}
if p.DestinationCA != "" {
rrForPath.TLS.DestinationCA = p.DestinationCA
Expand Down
Loading
Loading