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

--default-ssl-certificate flag for via CRD #160

Merged
merged 24 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e6e947d
Squashed Changes for DefaultSSLCertificate
aamgayle Jan 29, 2024
1e5b5e1
small refactor and ingress controller test
aamgayle Jan 29, 2024
1907fc1
nginx test with ssl cert
aamgayle Jan 29, 2024
1be3cbe
CRD update and small refactor
aamgayle Jan 29, 2024
cb5af4c
tests (unit/e2e) and CRD update
aamgayle Jan 29, 2024
1196135
inherit immutable fields in placeholder pod reconciler (#153)
OliverMKing Jan 23, 2024
b88e386
add 0.2.1 to changelog (#154)
OliverMKing Jan 23, 2024
5e20b87
Bump golang.org/x/crypto from 0.12.0 to 0.17.0 (#146)
dependabot[bot] Jan 29, 2024
96dcb7c
updates to CRD and tests
aamgayle Jan 29, 2024
cfd147d
Merge branch 'main' into aamgayle/defaultsslcertargcopy
aamgayle Jan 30, 2024
f0a2b60
small refactor
aamgayle Jan 30, 2024
08979eb
Added field name for Secret
aamgayle Jan 30, 2024
bb2ca17
Addressing comments
aamgayle Jan 30, 2024
0298201
removed invalid defaultsslcert message from reconciler
aamgayle Jan 30, 2024
96aff17
Fixed nginx ingress controller test
aamgayle Jan 30, 2024
79db9cd
fixed nginx_test
aamgayle Jan 30, 2024
2b98ddc
added nil check for DefaultSSLCertificate
aamgayle Jan 30, 2024
c3c2790
Updated comments and added CEL validation for Secret
aamgayle Jan 31, 2024
c5ba151
More cases for unit testing and returning e2e tests
aamgayle Jan 31, 2024
9c797bc
More cases for unit testing and returning e2e tests
aamgayle Jan 31, 2024
9374b59
Removed redundant CEL validation for secret fields
aamgayle Feb 1, 2024
7614337
Merge branch 'main' into aamgayle/defaultsslcertargcopy
aamgayle Feb 1, 2024
a3b7596
Merge branch 'main' into aamgayle/defaultsslcertargcopy
aamgayle Feb 1, 2024
7eff4ed
Fixed e2e test
aamgayle Feb 2, 2024
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
22 changes: 22 additions & 0 deletions api/v1alpha1/nginxingresscontroller_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,28 @@ type NginxIngressControllerSpec struct {
// will be from the Azure LoadBalancer annotations here https://cloud-provider-azure.sigs.k8s.io/topics/loadbalancer/#loadbalancer-annotations
// +optional
LoadBalancerAnnotations map[string]string `json:"loadBalancerAnnotations,omitempty"`

// DefaultSSLCertificate is a struct with a secret with the fields namespace and name which is used to create the ssl certificate used by the default HTTPS server
aamgayle marked this conversation as resolved.
Show resolved Hide resolved
// +optional
DefaultSSLCertificate *DefaultSSLCertificate `json:"defaultSSLCertificate,omitempty"`
}

type DefaultSSLCertificate struct {
// Secret is a struct that holds the name and namespace fields used for the default ssl secret
// +optional
Secret *Secret `json:"secret"`
aamgayle marked this conversation as resolved.
Show resolved Hide resolved
aamgayle marked this conversation as resolved.
Show resolved Hide resolved
}

type Secret struct {
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
// +kubebuilder:validation:Pattern=`^[a-z0-9][-a-z0-9\.]*[a-z0-9]$`
Name string `json:"name"`

// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
// +kubebuilder:validation:Pattern=`^[a-z0-9][-a-z0-9\.]*[a-z0-9]$`
Namespace string `json:"namespace"`
}

// NginxIngressControllerStatus defines the observed state of NginxIngressController
Expand Down
40 changes: 40 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,30 @@ spec:
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
defaultSSLCertificate:
description: DefaultSSLCertificate is a struct with a secret with
the fields namespace and name which is used to create the ssl certificate
used by the default HTTPS server
properties:
secret:
description: Secret is a struct that holds the name and namespace
fields used for the default ssl secret
properties:
name:
maxLength: 253
minLength: 1
pattern: ^[a-z0-9][-a-z0-9\.]*[a-z0-9]$
type: string
namespace:
maxLength: 253
minLength: 1
pattern: ^[a-z0-9][-a-z0-9\.]*[a-z0-9]$
type: string
required:
- name
- namespace
type: object
type: object
ingressClassName:
default: nginx.approuting.kubernetes.azure.com
description: IngressClassName is the name of the IngressClass that
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ require (
github.com/prometheus/common v0.44.0
github.com/stretchr/testify v1.8.4
go.uber.org/zap v1.25.0
gomodules.xyz/jsonpatch/v2 v2.4.0
k8s.io/api v0.28.1
k8s.io/apiextensions-apiserver v0.28.1
k8s.io/apimachinery v0.28.1
Expand Down Expand Up @@ -73,6 +72,7 @@ require (
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
Expand Down
9 changes: 8 additions & 1 deletion pkg/controller/nginxingress/nginx_ingress_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,12 +518,19 @@ func ToNginxIngressConfig(nic *approutingv1alpha1.NginxIngressController, defaul
resourceName = DefaultNicResourceName
}

return &manifests.NginxIngressConfig{
nginxIng := &manifests.NginxIngressConfig{
ControllerClass: cc,
ResourceName: resourceName,
IcName: nic.Spec.IngressClassName,
ServiceConfig: &manifests.ServiceConfig{
Annotations: nic.Spec.LoadBalancerAnnotations,
},
}

if nic.Spec.DefaultSSLCertificate != nil &&
nic.Spec.DefaultSSLCertificate.Secret.Name != "" && nic.Spec.DefaultSSLCertificate.Secret.Namespace != "" {
nginxIng.DefaultSSLCertificate = nic.Spec.DefaultSSLCertificate.Secret.Namespace + "/" + nic.Spec.DefaultSSLCertificate.Secret.Name
}

return nginxIng
}
30 changes: 30 additions & 0 deletions pkg/controller/nginxingress/nginx_ingress_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,12 @@ func TestIsUnreconcilableError(t *testing.T) {

func TestToNginxIngressConfig(t *testing.T) {
defaultCc := "defaultControllerClass"
FakeDefaultSSLCert := &approutingv1alpha1.DefaultSSLCertificate{
aamgayle marked this conversation as resolved.
Show resolved Hide resolved
Secret: &approutingv1alpha1.Secret{
Name: "fakename",
Namespace: "fakenamespace",
},
}
cases := []struct {
name string
nic *approutingv1alpha1.NginxIngressController
Expand Down Expand Up @@ -883,6 +889,30 @@ func TestToNginxIngressConfig(t *testing.T) {
IcName: "ingressClassName",
},
},
{
name: "default controller class with DefaultSSLCertificate",
nic: &approutingv1alpha1.NginxIngressController{
TypeMeta: metav1.TypeMeta{
APIVersion: approutingv1alpha1.GroupVersion.String(),
Kind: "NginxIngressController",
},
ObjectMeta: metav1.ObjectMeta{
Name: DefaultNicName,
},
Spec: approutingv1alpha1.NginxIngressControllerSpec{
ControllerNamePrefix: DefaultNicResourceName,
IngressClassName: DefaultIcName,
DefaultSSLCertificate: FakeDefaultSSLCert,
},
},
want: manifests.NginxIngressConfig{
ControllerClass: defaultCc,
ResourceName: DefaultNicResourceName,
IcName: DefaultIcName,
ServiceConfig: &manifests.ServiceConfig{},
DefaultSSLCertificate: FakeDefaultSSLCert.Secret.Namespace + "/" + FakeDefaultSSLCert.Secret.Name,
},
},
}

for _, c := range cases {
Expand Down
Loading
Loading