Skip to content

Commit

Permalink
Merge pull request #30 from Ragin-LundF/feature/support_external_dns
Browse files Browse the repository at this point in the history
Feature/support external dns
  • Loading branch information
Ragin-LundF authored Nov 11, 2020
2 parents 0374ac5 + 4b85c2c commit 15368c5
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 31 deletions.
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
# 2.8.0
## Bugfixes
This version fixes a problem with the namespace events after creating a new project.

## External DNS annotations
This version introduces support for external DNS annotations on the Nginx load balancer service.
To activate it, the following configurations can be changed in your project configuration:

```bash
# enable annotations on the load balancer service
NGINX_LOADBALANCER_ANNOTATIONS_ENABLED=false

# external DNS hostname
NGINX_LOADBALANCER_ANNOTATIONS_EXT_DNS_HOSTNAME="domain.tld"
# external DNS TTL time in seconds
NGINX_LOADBALANCER_ANNOTATIONS_EXT_DNS_TTL=60
```

These values are replacing the annotations block in the [nginx_ingress_helm_values.yaml](templates/nginx_ingress_helm_values.yaml):
```yaml
annotations:
enabled: ##NGINX_LOADBALANCER_ANNOTATIONS_ENABLED##
external_dns_hostname: "##NAMESPACE##.##NGINX_LOADBALANCER_ANNOTATIONS_EXT_DNS_HOSTNAME##"
external_dns_ttl: ##NGINX_LOADBALANCER_ANNOTATIONS_EXT_DNS_TTL##
```
The default for new DNS names is `<namespace>.<ext_dns_host>`.
This version supports no direct UI edit (but it is possible to abuse e.g. the Jenkins Welcome Message).

Please update this file in the project templates, if modified templates are used.

If own charts are used, please update the following files in the `nginx-ingress-controller` folder:
- [templates/loadbalancer.yaml](charts/nginx-ingress-controller/templates/loadbalancer.yaml)
- [values.yaml](charts/nginx-ingress-controller/values.yaml)


# 2.7.0
This release mainly updates the underlying fyne.io framework to version 1.4.0.
With this update the UI is much better and gets a fresher color scheme.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.0
2.8.0
10 changes: 10 additions & 0 deletions app/actions/createprojectactions/nginx_template_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ func ActionReplaceGlobalConfigNginxIngressCtrlHelmValues(projectDirectory string
if success, err = files.ReplaceStringInFile(nginxHelmValuesFile, constants.TemplateNginxLoadbalancerHTTPSTargetPort, strconv.FormatUint(models.GetConfiguration().LoadBalancer.Port.HTTPSTarget, 10)); !success {
return success, err
}
// Loadbalancer annotations placeholder
if success, err = files.ReplaceStringInFile(nginxHelmValuesFile, constants.TemplateNginxLoadbalancerAnnotationsEnabled, strconv.FormatBool(models.GetConfiguration().LoadBalancer.Annotations.Enabled)); !success {
return success, err
}
if success, err = files.ReplaceStringInFile(nginxHelmValuesFile, constants.TemplateNginxLoadbalancerAnnotationsExtDnsHostname, models.GetConfiguration().LoadBalancer.Annotations.ExtDNS.Hostname); !success {
return success, err
}
if success, err = files.ReplaceStringInFile(nginxHelmValuesFile, constants.TemplateNginxLoadbalancerAnnotationsExtDnsTtl, strconv.FormatUint(models.GetConfiguration().LoadBalancer.Annotations.ExtDNS.Ttl, 10)); !success {
return success, err
}
}
return true, nil
}
9 changes: 9 additions & 0 deletions app/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,15 @@ const TemplateNginxLoadbalancerHTTPSPort = "##NGINX_LOADBALANCER_HTTPS_PORT##"
// TemplateNginxLoadbalancerHTTPSTargetPort : Placeholder for Nginx load balancer HTTPS target port
const TemplateNginxLoadbalancerHTTPSTargetPort = "##NGINX_LOADBALANCER_HTTPS_TARGETPORT##"

// TemplateNginxLoadbalancerAnnotationsEnabled : Placeholder for Nginx Annotation support
const TemplateNginxLoadbalancerAnnotationsEnabled = "##NGINX_LOADBALANCER_ANNOTATIONS_ENABLED##"

// TemplateNginxLoadbalancerAnnotationsExtDnsTtl : Placeholder for external DNS TTL annotation
const TemplateNginxLoadbalancerAnnotationsExtDnsTtl = "##NGINX_LOADBALANCER_ANNOTATIONS_EXT_DNS_TTL##"

// TemplateNginxLoadbalancerAnnotationsExtDnsTtl : Placeholder for external DNS hostname annotation
const TemplateNginxLoadbalancerAnnotationsExtDnsHostname = "##NGINX_LOADBALANCER_ANNOTATIONS_EXT_DNS_HOSTNAME##"

// TemplateKubernetesServerCertificate : Placeholder for Kubernetes server certificate
const TemplateKubernetesServerCertificate = "##KUBERNETES_SERVER_CERTIFICATE##"

Expand Down
7 changes: 4 additions & 3 deletions app/gui/install/install_gui_screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"time"
)

var namespaceSelectEntry *widget.SelectEntry
var namespaceErrorLabel = widget.NewLabel("")
var namespaceSelectEntry = uielements.CreateNamespaceSelectEntry(namespaceErrorLabel)

// ScreenInstall shows the install screen
func ScreenInstall(window fyne.Window) fyne.CanvasObject {
Expand All @@ -28,7 +28,6 @@ func ScreenInstall(window fyne.Window) fyne.CanvasObject {
var secretsPasswords string

// Entries
var namespaceSelectEntry = uielements.CreateNamespaceSelectEntry(namespaceErrorLabel)
var secretsFileSelect = uielements.CreateSecretsFileEntry()
var deploymentNameEntry = uielements.CreateDeploymentNameEntry()
var installTypeRadio = uielements.CreateInstallTypeRadio()
Expand Down Expand Up @@ -123,7 +122,9 @@ type namespaceCreatedNotifier struct {

func (notifier namespaceCreatedNotifier) Handle(payload events.NamespaceCreatedPayload) {
logger.Log().Info("[install_gui] -> Retrieved event to that new namespace was created")
namespaceSelectEntry.SetOptions(namespaceactions.ActionReadNamespaceWithFilter(nil))
if namespaceSelectEntry != nil {
namespaceSelectEntry.SetOptions(namespaceactions.ActionReadNamespaceWithFilter(nil))
}

events.RefreshTabs.Trigger(events.RefreshTabsPayload{
Time: time.Now(),
Expand Down
4 changes: 3 additions & 1 deletion app/gui/namespace/create_namespace_gui_screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ type namespaceCreatedNotifier struct {

func (notifier namespaceCreatedNotifier) Handle(payload events.NamespaceCreatedPayload) {
logger.Log().Info("[namespace_gui] -> Retrieved event to that new namespace was created")
namespaceSelectEntry.SetOptions(namespaceactions.ActionReadNamespaceWithFilter(nil))
if namespaceSelectEntry != nil {
namespaceSelectEntry.SetOptions(namespaceactions.ActionReadNamespaceWithFilter(nil))
}

events.RefreshTabs.Trigger(events.RefreshTabsPayload{
Time: time.Now(),
Expand Down
7 changes: 4 additions & 3 deletions app/gui/secrets/apply_secrets_gui_screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

// Namespace
var namespaceErrorLabel = widget.NewLabel("")
var namespaceSelectEntry *widget.SelectEntry
var namespaceSelectEntry = uielements.CreateNamespaceSelectEntry(namespaceErrorLabel)

// ScreenApplySecretsToAllNamespace shows the apply to all namespaces screen
func ScreenApplySecretsToAllNamespace(window fyne.Window) fyne.CanvasObject {
Expand Down Expand Up @@ -56,7 +56,6 @@ func ScreenApplySecretsToAllNamespace(window fyne.Window) fyne.CanvasObject {
func ScreenApplySecretsToNamespace(window fyne.Window) fyne.CanvasObject {
var secretsFiles = uielements.CreateSecretsFileEntry()
var passwordEntry = widget.NewPasswordEntry()
var namespaceSelectEntry = uielements.CreateNamespaceSelectEntry(namespaceErrorLabel)

var form = &widget.Form{
Items: []*widget.FormItem{
Expand Down Expand Up @@ -94,7 +93,9 @@ type namespaceCreatedNotifier struct {

func (notifier namespaceCreatedNotifier) Handle(payload events.NamespaceCreatedPayload) {
logger.Log().Info("[secrets_gui] -> Retrieved event to that new namespace was created")
namespaceSelectEntry.SetOptions(namespaceactions.ActionReadNamespaceWithFilter(nil))
if namespaceSelectEntry != nil {
namespaceSelectEntry.SetOptions(namespaceactions.ActionReadNamespaceWithFilter(nil))
}

events.RefreshTabs.Trigger(events.RefreshTabsPayload{
Time: time.Now(),
Expand Down
7 changes: 4 additions & 3 deletions app/gui/uninstall/uninstall_gui_screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

// Namespace
var namespaceErrorLabel = widget.NewLabel("")
var namespaceSelectEntry *widget.SelectEntry
var namespaceSelectEntry = uielements.CreateNamespaceSelectEntry(namespaceErrorLabel)

// ScreenUninstall shows the uninstall screen
func ScreenUninstall(window fyne.Window) fyne.CanvasObject {
Expand All @@ -32,7 +32,6 @@ func ScreenUninstall(window fyne.Window) fyne.CanvasObject {

// Dry-run or execute
var dryRunRadio = uielements.CreateDryRunRadio()
namespaceSelectEntry = uielements.CreateNamespaceSelectEntry(namespaceErrorLabel)

var form = &widget.Form{
Items: []*widget.FormItem{
Expand Down Expand Up @@ -97,7 +96,9 @@ type namespaceCreatedNotifier struct {

func (notifier namespaceCreatedNotifier) Handle(payload events.NamespaceCreatedPayload) {
logger.Log().Info("[uninstall_gui] -> Retrieved event to that new namespace was created")
namespaceSelectEntry.SetOptions(namespaceactions.ActionReadNamespaceWithFilter(nil))
if namespaceSelectEntry != nil {
namespaceSelectEntry.SetOptions(namespaceactions.ActionReadNamespaceWithFilter(nil))
}

events.RefreshTabs.Trigger(events.RefreshTabsPayload{
Time: time.Now(),
Expand Down
19 changes: 19 additions & 0 deletions app/models/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ type Configuration struct {
HTTPS uint64
HTTPSTarget uint64
}
Annotations struct {
Enabled bool
ExtDNS struct {
Ttl uint64
Hostname string
}
}
}
// Kubernetes relevant data
Kubernetes struct {
Expand Down Expand Up @@ -414,6 +421,18 @@ func addLoadBalancerConfig(key string, value string) (success bool) {
configuration.LoadBalancer.Port.HTTPSTarget, _ = strconv.ParseUint(value, 10, 16)
success = true
break
case "NGINX_LOADBALANCER_ANNOTATIONS_ENABLED":
configuration.LoadBalancer.Annotations.Enabled, _ = strconv.ParseBool(value)
success = true
break
case "NGINX_LOADBALANCER_ANNOTATIONS_EXT_DNS_HOSTNAME":
configuration.LoadBalancer.Annotations.ExtDNS.Hostname = value
success = true
break
case "NGINX_LOADBALANCER_ANNOTATIONS_EXT_DNS_TTL":
configuration.LoadBalancer.Annotations.ExtDNS.Ttl, _ = strconv.ParseUint(value, 10, 16)
success = true
break
}
return success
}
Expand Down
9 changes: 9 additions & 0 deletions charts/nginx-ingress-controller/templates/loadbalancer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ metadata:
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
{{- if .Values.k8sJenkinsMgmt.loadbalancer.annotations.enabled}}
annotations:
{{- if .Values.k8sJenkinsMgmt.loadbalancer.annotations.external_dns_hostname }}
external-dns.alpha.kubernetes.io/hostname: {{ .Values.k8sJenkinsMgmt.loadbalancer.annotations.external_dns_hostname }}}}
{{- end }}
{{- if .Values.k8sJenkinsMgmt.loadbalancer.annotations.external_dns_ttl }}
external-dns.alpha.kubernetes.io/ttl: {{ .Values.k8sJenkinsMgmt.loadbalancer.annotations.external_dns_ttl }}}}
{{- end }}

spec:
# externalTrafficPolicy: Local
type: LoadBalancer
Expand Down
4 changes: 4 additions & 0 deletions charts/nginx-ingress-controller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ k8sJenkinsMgmt:
enabled: false
loadbalancer:
enabled: false
annotations:
enabled: false
external_dns_hostname: "my.domain.tld,another.domain.tld"
external_dns_ttl: 60
ports:
http:
port: 80
Expand Down
7 changes: 7 additions & 0 deletions config/k8s_jcasc_mgmt.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ NGINX_LOADBALANCER_HTTP_TARGETPORT=80
NGINX_LOADBALANCER_HTTPS_PORT=443
NGINX_LOADBALANCER_HTTPS_TARGETPORT=443

# enable annotations on the load balancer service
NGINX_LOADBALANCER_ANNOTATIONS_ENABLED=false

# external DNS hostname
NGINX_LOADBALANCER_ANNOTATIONS_EXT_DNS_HOSTNAME="domain.tld"
# external DNS TTL time in seconds
NGINX_LOADBALANCER_ANNOTATIONS_EXT_DNS_TTL=60

# default certificate of the Kubernetes server
KUBERNETES_SERVER_CERTIFICATE=LS0tLS1DeUdJTiBDRVJUSUZJQ0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bzVPb1FEF21nRXhFVlpsRnJKaXFZYjYwR3Z6Q0RHblZUc3ljT2xqaVJmeGdWSFQvR8t6bkEKbG9scTY4Z2VlVGFZMWZjdWZTK3FPcHBKcm9CNjZvZENtenhuMExVZE4yRU9ucDJYZUdIZ0hjRzRFcFVXODdXcQpJZVZTTkY3SDFIYVlqY0Z2ZD3SZHFseVVpRjkvaWwxMFJYVHTSbzNPa3loZ3BzWnPUNWRBTk9jOXA0M0MKNHF0CjNwZDJvN2hHRGxVc3g4cFpsaZZHamo4ZA8rVy9qRXY1K1VTQzVPQ09kRHJJU2c9PQotLS0tLUVORCBDRVJUSUZMR0FUSS0tBT0t
Expand Down
44 changes: 24 additions & 20 deletions templates/nginx_ingress_helm_values.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
k8sJenkinsMgmt:
ingress:
annotationIngressClass: ##NGINX_INGRESS_ANNOTATION_CLASS##
namespace: ##NAMESPACE##
loadbalancerIp: ##PUBLIC_IP_ADDRESS##
deploymentName: ##NGINX_INGRESS_DEPLOYMENT_NAME##
jenkinsDeploymentName: ##JENKINS_MASTER_DEPLOYMENT_NAME##
jenkinsUriPrefix: ##JENKINS_MASTER_DEFAULT_URI_PREFIX##
containerImage: ##NGINX_INGRESS_CONTROLLER_CONTAINER_IMAGE##
imagePullSecrets: ##NGINX_INGRESS_CONTROLLER_CONTAINER_PULL_SECRETS##
controllerForNamespace:
enabled: ##NGINX_INGRESS_CONTROLLER_FOR_NAMESPACE##
loadbalancer:
enabled: ##NGINX_LOADBALANCER_ENABLED##
ports:
http:
port: ##NGINX_LOADBALANCER_HTTP_PORT##
targetPort: ##NGINX_LOADBALANCER_HTTP_TARGETPORT##
https:
port: ##NGINX_LOADBALANCER_HTTPS_PORT##
targetPort: ##NGINX_LOADBALANCER_HTTPS_TARGETPORT##
ingress:
annotationIngressClass: ##NGINX_INGRESS_ANNOTATION_CLASS##
namespace: ##NAMESPACE##
loadbalancerIp: ##PUBLIC_IP_ADDRESS##
deploymentName: ##NGINX_INGRESS_DEPLOYMENT_NAME##
jenkinsDeploymentName: ##JENKINS_MASTER_DEPLOYMENT_NAME##
jenkinsUriPrefix: ##JENKINS_MASTER_DEFAULT_URI_PREFIX##
containerImage: ##NGINX_INGRESS_CONTROLLER_CONTAINER_IMAGE##
imagePullSecrets: ##NGINX_INGRESS_CONTROLLER_CONTAINER_PULL_SECRETS##
controllerForNamespace:
enabled: ##NGINX_INGRESS_CONTROLLER_FOR_NAMESPACE##
loadbalancer:
enabled: ##NGINX_LOADBALANCER_ENABLED##
ports:
http:
port: ##NGINX_LOADBALANCER_HTTP_PORT##
targetPort: ##NGINX_LOADBALANCER_HTTP_TARGETPORT##
https:
port: ##NGINX_LOADBALANCER_HTTPS_PORT##
targetPort: ##NGINX_LOADBALANCER_HTTPS_TARGETPORT##
annotations:
enabled: ##NGINX_LOADBALANCER_ANNOTATIONS_ENABLED##
external_dns_hostname: "##NAMESPACE##.##NGINX_LOADBALANCER_ANNOTATIONS_EXT_DNS_HOSTNAME##"
external_dns_ttl: ##NGINX_LOADBALANCER_ANNOTATIONS_EXT_DNS_TTL##

0 comments on commit 15368c5

Please sign in to comment.