Skip to content

Commit

Permalink
feat: expose admin port as a service
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Horton <phorton@sonatype.com>
  • Loading branch information
madpah committed Mar 29, 2023
1 parent 82d1226 commit 49a6b1a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 3 deletions.
6 changes: 5 additions & 1 deletion modules/nxiq-ha-cluster/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ server:
applicationContextPath: /
applicationConnectors:
- type: http
port: 8070
port: 8070
adminContextPath: /
adminConnectors:
- type: http
port: 8071
32 changes: 31 additions & 1 deletion modules/nxiq-ha-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,15 @@ resource "kubernetes_deployment" "nxiq" {
}

port {
name = "app"
container_port = 8070
}

port {
name = "admin"
container_port = 8071
}

security_context {
run_as_user = 1000
}
Expand Down Expand Up @@ -224,7 +230,7 @@ resource "kubernetes_deployment" "nxiq" {
# --------------------------------------------------------------------------
# Create k8s Service
# --------------------------------------------------------------------------
resource "kubernetes_service" "nxiq" {
resource "kubernetes_service" "nxiq-app" {
metadata {
name = "nxiq-ha-${var.nxiq_name}-svc"
namespace = local.namespace
Expand All @@ -247,3 +253,27 @@ resource "kubernetes_service" "nxiq" {
type = "NodePort"
}
}

resource "kubernetes_service" "nxiq-admin" {
metadata {
name = "nxiq-ha-${var.nxiq_name}-admin-svc"
namespace = local.namespace
labels = {
app = "nxiq-ha"
}
}
spec {
selector = {
app = kubernetes_deployment.nxiq.metadata.0.labels.app
}

port {
name = "http"
port = 8071
target_port = 8071
protocol = "TCP"
}

type = "NodePort"
}
}
10 changes: 9 additions & 1 deletion modules/nxiq-ha-cluster/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ output "nxiq_ha_k8s_namespace" {
}

output "nxiq_ha_k8s_service_id" {
value = kubernetes_service.nxiq.id
value = kubernetes_service.nxiq-app.id
}

output "nxiq_ha_k8s_service_name" {
value = "nxiq-ha-${var.nxiq_name}-svc"
}

output "nxiq_ha_k8s_admin_service_id" {
value = kubernetes_service.nxiq-admin.id
}

output "nxiq_ha_k8s_admin_service_name" {
value = "nxiq-ha-${var.nxiq_name}-admin-svc"
}
8 changes: 8 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ output "nxiq_ha_k8s_service_id" {
output "nxiq_ha_k8s_service_name" {
value = module.nxiq_ha_cluster.nxiq_ha_k8s_service_name
}

output "nxiq_ha_k8s_admin_service_id" {
value = module.nxiq_ha_cluster.nxiq_ha_k8s_admin_service_id
}

output "nxiq_ha_k8s_admin_service_name" {
value = module.nxiq_ha_cluster.nxiq_ha_k8s_admin_service_name
}

0 comments on commit 49a6b1a

Please sign in to comment.