Skip to content

Commit

Permalink
fix: use unique names for a service's ingresses
Browse files Browse the repository at this point in the history
Before this fix, services defining multiple ingresses would only have
the last configured ingress deployed to the cluster (since each ingress
for a given service had metadata.name = service.name).
  • Loading branch information
thsig committed Mar 18, 2019
1 parent d8ef17a commit b1fbb25
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions examples/simple-project/services/node-service/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ module:
ports:
- name: http
containerPort: 8080
healthCheck:
httpGet:
path: /hello-node
port: http
ingresses:
- path: /hello-node
port: http
Expand Down
4 changes: 2 additions & 2 deletions garden-service/src/plugins/kubernetes/container/ingress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function createIngressResources(

const allIngresses = await getIngressesWithCert(service, api, provider)

return Bluebird.map(allIngresses, async (ingress) => {
return Bluebird.map(allIngresses, async (ingress, index) => {
const rules = [{
host: ingress.hostname,
http: {
Expand Down Expand Up @@ -74,7 +74,7 @@ export async function createIngressResources(
apiVersion: "extensions/v1beta1",
kind: "Ingress",
metadata: {
name: service.name,
name: `${service.name}-${index}`,
annotations,
namespace,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ describe("createIngressResources", () => {
apiVersion: "extensions/v1beta1",
kind: "Ingress",
metadata: {
name: service.name,
name: `${service.name}-0`,
annotations: {
"ingress.kubernetes.io/force-ssl-redirect": "false",
"kubernetes.io/ingress.class": "nginx",
Expand Down Expand Up @@ -450,7 +450,7 @@ describe("createIngressResources", () => {
apiVersion: "extensions/v1beta1",
kind: "Ingress",
metadata: {
name: service.name,
name: `${service.name}-0`,
annotations: {
"ingress.kubernetes.io/force-ssl-redirect": "false",
"kubernetes.io/ingress.class": "nginx",
Expand Down Expand Up @@ -502,7 +502,7 @@ describe("createIngressResources", () => {
apiVersion: "extensions/v1beta1",
kind: "Ingress",
metadata: {
name: service.name,
name: `${service.name}-0`,
annotations: {
"ingress.kubernetes.io/force-ssl-redirect": "false",
"kubernetes.io/ingress.class": "nginx",
Expand Down Expand Up @@ -530,7 +530,7 @@ describe("createIngressResources", () => {
apiVersion: "extensions/v1beta1",
kind: "Ingress",
metadata: {
name: service.name,
name: `${service.name}-1`,
annotations: {
"ingress.kubernetes.io/force-ssl-redirect": "false",
"kubernetes.io/ingress.class": "nginx",
Expand Down Expand Up @@ -575,7 +575,7 @@ describe("createIngressResources", () => {
apiVersion: "extensions/v1beta1",
kind: "Ingress",
metadata: {
name: service.name,
name: `${service.name}-0`,
annotations: {
"ingress.kubernetes.io/force-ssl-redirect": "true",
"kubernetes.io/ingress.class": "nginx",
Expand Down Expand Up @@ -722,7 +722,7 @@ describe("createIngressResources", () => {
apiVersion: "extensions/v1beta1",
kind: "Ingress",
metadata: {
name: service.name,
name: `${service.name}-0`,
annotations: {
"ingress.kubernetes.io/force-ssl-redirect": "true",
"kubernetes.io/ingress.class": "nginx",
Expand Down Expand Up @@ -788,7 +788,7 @@ describe("createIngressResources", () => {
apiVersion: "extensions/v1beta1",
kind: "Ingress",
metadata: {
name: service.name,
name: `${service.name}-0`,
annotations: {
"ingress.kubernetes.io/force-ssl-redirect": "true",
"kubernetes.io/ingress.class": "nginx",
Expand Down

0 comments on commit b1fbb25

Please sign in to comment.