Expose port 80 and 443 on Google Container Engine without load balancerKubernetes - can I avoid using the GCE...
Is there a familial term for apples and pears?
Denied boarding due to overcrowding, Sparpreis ticket. What are my rights?
Unbreakable Formation vs. Cry of the Carnarium
Can I legally use front facing blue light in the UK?
Why was the "bread communication" in the arena of Catching Fire left out in the movie?
What does "enim et" mean?
Does the average primeness of natural numbers tend to zero?
How can I add custom success page
How to answer pointed "are you quitting" questioning when I don't want them to suspect
OA final episode explanation
Are objects structures and/or vice versa?
Was there ever an axiom rendered a theorem?
How did the USSR manage to innovate in an environment characterized by government censorship and high bureaucracy?
Are cabin dividers used to "hide" the flex of the airplane?
Why do we use polarized capacitors?
Is it wise to focus on putting odd beats on left when playing double bass drums?
Add an angle to a sphere
What is the command to reset a PC without deleting any files
Manga about a female worker who got dragged into another world together with this high school girl and she was just told she's not needed anymore
Symmetry in quantum mechanics
Is Social Media Science Fiction?
Some basic questions on halt and move in Turing machines
Is Fable (1996) connected in any way to the Fable franchise from Lionhead Studios?
Need help identifying/translating a plaque in Tangier, Morocco
Expose port 80 and 443 on Google Container Engine without load balancer
Kubernetes - can I avoid using the GCE Load Balancer to reduce cost?Exposing port 80 and 443 on Google kubernetes loadbalancer serviceHow to create an internal/private load balancer in google compute enginegoogle cloud http(s) load balancer returning 502 despite healthy backend serviceGoogle container engine / Kubernetes 1.1.1 - Service LoadBalancer not being createdGCP LB with static website and kubernetesBroken GKE Backend Health Check DefaultNGINX vs. GCE Kubernetes ingress classessocket.io handshake fails on Google https load balancerGCE NGINX Ingress does not use controllerGoogle Compute Engine App nothing listening on ports 80 and 443
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Currently I'm working on a small hobby project which I'll make open source once it's ready. This service is running on Google Container Engine.
I chose GCE to avoid configuration hassle, the costs are affordable and to learn new stuff.
My pods are running fine and I created a service with type LoadBalancer to expose the service on port 80 and 443. This works perfectly.
However, I discovered that for each LoadBalancer service, a new Google Compute Engine load balancer is created. This load balancer pretty expensive and really over done for a hobby project on a single instance.
To cut the costs I'm looking for a way to expose the ports without the load balancer.
What i've tried so far:
Deploy a
NodePortservice. Unfortunately it's disallowed to expose a
port below 30000.Deploy an Ingress but this also creates a load balancer.
Tried to disable
HttpLoadBalancing(https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters#HttpLoadBalancing) but it still creates a load balancer.
Is there a way to expose port 80 and 443 for a single instance on Google Container Engine without a load balancer?
add a comment |
Currently I'm working on a small hobby project which I'll make open source once it's ready. This service is running on Google Container Engine.
I chose GCE to avoid configuration hassle, the costs are affordable and to learn new stuff.
My pods are running fine and I created a service with type LoadBalancer to expose the service on port 80 and 443. This works perfectly.
However, I discovered that for each LoadBalancer service, a new Google Compute Engine load balancer is created. This load balancer pretty expensive and really over done for a hobby project on a single instance.
To cut the costs I'm looking for a way to expose the ports without the load balancer.
What i've tried so far:
Deploy a
NodePortservice. Unfortunately it's disallowed to expose a
port below 30000.Deploy an Ingress but this also creates a load balancer.
Tried to disable
HttpLoadBalancing(https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters#HttpLoadBalancing) but it still creates a load balancer.
Is there a way to expose port 80 and 443 for a single instance on Google Container Engine without a load balancer?
add a comment |
Currently I'm working on a small hobby project which I'll make open source once it's ready. This service is running on Google Container Engine.
I chose GCE to avoid configuration hassle, the costs are affordable and to learn new stuff.
My pods are running fine and I created a service with type LoadBalancer to expose the service on port 80 and 443. This works perfectly.
However, I discovered that for each LoadBalancer service, a new Google Compute Engine load balancer is created. This load balancer pretty expensive and really over done for a hobby project on a single instance.
To cut the costs I'm looking for a way to expose the ports without the load balancer.
What i've tried so far:
Deploy a
NodePortservice. Unfortunately it's disallowed to expose a
port below 30000.Deploy an Ingress but this also creates a load balancer.
Tried to disable
HttpLoadBalancing(https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters#HttpLoadBalancing) but it still creates a load balancer.
Is there a way to expose port 80 and 443 for a single instance on Google Container Engine without a load balancer?
Currently I'm working on a small hobby project which I'll make open source once it's ready. This service is running on Google Container Engine.
I chose GCE to avoid configuration hassle, the costs are affordable and to learn new stuff.
My pods are running fine and I created a service with type LoadBalancer to expose the service on port 80 and 443. This works perfectly.
However, I discovered that for each LoadBalancer service, a new Google Compute Engine load balancer is created. This load balancer pretty expensive and really over done for a hobby project on a single instance.
To cut the costs I'm looking for a way to expose the ports without the load balancer.
What i've tried so far:
Deploy a
NodePortservice. Unfortunately it's disallowed to expose a
port below 30000.Deploy an Ingress but this also creates a load balancer.
Tried to disable
HttpLoadBalancing(https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters#HttpLoadBalancing) but it still creates a load balancer.
Is there a way to expose port 80 and 443 for a single instance on Google Container Engine without a load balancer?
edited Sep 7 '16 at 4:28
Ruben Ernst
asked Sep 5 '16 at 18:26
Ruben ErnstRuben Ernst
9816
9816
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
Yep, through externalIPs on the service. Example service I've used:
apiVersion: v1
kind: Service
metadata:
name: bind
labels:
app: bind
version: 3.0.0
spec:
ports:
- port: 53
protocol: UDP
selector:
app: bind
version: 3.0.0
externalIPs:
- a.b.c.d
- a.b.c.e
Please be aware that the IPs listed in the config file must be the internal IP on GCE.
Thanks! But I think I missed something. The service is deployed but unable from the internet. I set the correct firewall rules. The service is displaying the correctexternalIp
– Ruben Ernst
Sep 16 '16 at 15:28
Sorry for late reply, forgot that I spent time on the exact same issue. The IPs listed need to be the internal IP, not external (At least on GCE).
– ConnorJC
Sep 18 '16 at 20:25
Thanks, that was the solution! Unfortunately I'm not allowed to upvote yet... I dropped this comment to let you know that this answer combined with the comment above (which was the key) solved my issue!
– Ruben Ernst
Sep 19 '16 at 6:14
1
Would you (or @RubenErnst) mind expanding on the answer a bit? In particular, "the IPs listed on GCE must be the intrenal IP." Which IP do you mean? Are you able to get this working with a static IP assigned to your single node cluster?
– Brett
Apr 18 '17 at 0:02
@Brett: Sorry for my late response. Is your question already answered in the meantime?
– Ruben Ernst
Oct 19 '17 at 8:28
|
show 2 more comments
In addition to ConnorJC's great and working solution: The same solution is also described in this question:
Kubernetes - can I avoid using the GCE Load Balancer to reduce cost?
The "internalIp" refers to the compute instance's (a.k.a. the node's) internal ip (as seen on Google Cloud Platform -> Google Compute Engine -> VM Instances)
This comment gives a hint at why the internal and not the external ip should be configured.
Furthermore, after having configured the service for ports 80 and 443, I had to create a firewall rule allowing traffic to my instance node:
gcloud compute firewall-rules create your-name-for-this-fw-rule --allow tcp:80,tcp:443 --source-ranges=0.0.0.0/0
After this setup, I could access my service through http(s)://externalIp
Using the node internal IP did the trick. 👍 Such confusion with the naming!
– James
Feb 23 at 0:40
add a comment |
If you only have exactly one pod, you can use hostNetwork: true to achieve this:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: caddy
spec:
replicas: 1
template:
metadata:
labels:
app: caddy
spec:
hostNetwork: true # <---------
containers:
- name: caddy
image: your_image
env:
- name: STATIC_BACKEND # example env in my custom image
value: $(STATIC_SERVICE_HOST):80
Note that by doing this your pod will inherit the host's DNS resolver and not Kubernetes'. That means you can no longer resolve cluster services by DNS name. For example, in the example above you cannot access the static service at http://static. You still can access services by their cluster IP, which are injected by environment variables.
This solution is better than using service's externalIP as it bypass kube-proxy, and you will receive the correct source IP.
add a comment |
I prefer not to use the cloud load balancers, until necessary, because of cost and vendor lock-in.
Instead I use this: https://kubernetes.github.io/ingress-nginx/deploy/
It's a pod that runs a load balancer for you. That page has GKE specific installation notes.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "2"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f801189%2fexpose-port-80-and-443-on-google-container-engine-without-load-balancer%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Yep, through externalIPs on the service. Example service I've used:
apiVersion: v1
kind: Service
metadata:
name: bind
labels:
app: bind
version: 3.0.0
spec:
ports:
- port: 53
protocol: UDP
selector:
app: bind
version: 3.0.0
externalIPs:
- a.b.c.d
- a.b.c.e
Please be aware that the IPs listed in the config file must be the internal IP on GCE.
Thanks! But I think I missed something. The service is deployed but unable from the internet. I set the correct firewall rules. The service is displaying the correctexternalIp
– Ruben Ernst
Sep 16 '16 at 15:28
Sorry for late reply, forgot that I spent time on the exact same issue. The IPs listed need to be the internal IP, not external (At least on GCE).
– ConnorJC
Sep 18 '16 at 20:25
Thanks, that was the solution! Unfortunately I'm not allowed to upvote yet... I dropped this comment to let you know that this answer combined with the comment above (which was the key) solved my issue!
– Ruben Ernst
Sep 19 '16 at 6:14
1
Would you (or @RubenErnst) mind expanding on the answer a bit? In particular, "the IPs listed on GCE must be the intrenal IP." Which IP do you mean? Are you able to get this working with a static IP assigned to your single node cluster?
– Brett
Apr 18 '17 at 0:02
@Brett: Sorry for my late response. Is your question already answered in the meantime?
– Ruben Ernst
Oct 19 '17 at 8:28
|
show 2 more comments
Yep, through externalIPs on the service. Example service I've used:
apiVersion: v1
kind: Service
metadata:
name: bind
labels:
app: bind
version: 3.0.0
spec:
ports:
- port: 53
protocol: UDP
selector:
app: bind
version: 3.0.0
externalIPs:
- a.b.c.d
- a.b.c.e
Please be aware that the IPs listed in the config file must be the internal IP on GCE.
Thanks! But I think I missed something. The service is deployed but unable from the internet. I set the correct firewall rules. The service is displaying the correctexternalIp
– Ruben Ernst
Sep 16 '16 at 15:28
Sorry for late reply, forgot that I spent time on the exact same issue. The IPs listed need to be the internal IP, not external (At least on GCE).
– ConnorJC
Sep 18 '16 at 20:25
Thanks, that was the solution! Unfortunately I'm not allowed to upvote yet... I dropped this comment to let you know that this answer combined with the comment above (which was the key) solved my issue!
– Ruben Ernst
Sep 19 '16 at 6:14
1
Would you (or @RubenErnst) mind expanding on the answer a bit? In particular, "the IPs listed on GCE must be the intrenal IP." Which IP do you mean? Are you able to get this working with a static IP assigned to your single node cluster?
– Brett
Apr 18 '17 at 0:02
@Brett: Sorry for my late response. Is your question already answered in the meantime?
– Ruben Ernst
Oct 19 '17 at 8:28
|
show 2 more comments
Yep, through externalIPs on the service. Example service I've used:
apiVersion: v1
kind: Service
metadata:
name: bind
labels:
app: bind
version: 3.0.0
spec:
ports:
- port: 53
protocol: UDP
selector:
app: bind
version: 3.0.0
externalIPs:
- a.b.c.d
- a.b.c.e
Please be aware that the IPs listed in the config file must be the internal IP on GCE.
Yep, through externalIPs on the service. Example service I've used:
apiVersion: v1
kind: Service
metadata:
name: bind
labels:
app: bind
version: 3.0.0
spec:
ports:
- port: 53
protocol: UDP
selector:
app: bind
version: 3.0.0
externalIPs:
- a.b.c.d
- a.b.c.e
Please be aware that the IPs listed in the config file must be the internal IP on GCE.
edited Aug 19 '17 at 13:49
answered Sep 16 '16 at 0:14
ConnorJCConnorJC
6501417
6501417
Thanks! But I think I missed something. The service is deployed but unable from the internet. I set the correct firewall rules. The service is displaying the correctexternalIp
– Ruben Ernst
Sep 16 '16 at 15:28
Sorry for late reply, forgot that I spent time on the exact same issue. The IPs listed need to be the internal IP, not external (At least on GCE).
– ConnorJC
Sep 18 '16 at 20:25
Thanks, that was the solution! Unfortunately I'm not allowed to upvote yet... I dropped this comment to let you know that this answer combined with the comment above (which was the key) solved my issue!
– Ruben Ernst
Sep 19 '16 at 6:14
1
Would you (or @RubenErnst) mind expanding on the answer a bit? In particular, "the IPs listed on GCE must be the intrenal IP." Which IP do you mean? Are you able to get this working with a static IP assigned to your single node cluster?
– Brett
Apr 18 '17 at 0:02
@Brett: Sorry for my late response. Is your question already answered in the meantime?
– Ruben Ernst
Oct 19 '17 at 8:28
|
show 2 more comments
Thanks! But I think I missed something. The service is deployed but unable from the internet. I set the correct firewall rules. The service is displaying the correctexternalIp
– Ruben Ernst
Sep 16 '16 at 15:28
Sorry for late reply, forgot that I spent time on the exact same issue. The IPs listed need to be the internal IP, not external (At least on GCE).
– ConnorJC
Sep 18 '16 at 20:25
Thanks, that was the solution! Unfortunately I'm not allowed to upvote yet... I dropped this comment to let you know that this answer combined with the comment above (which was the key) solved my issue!
– Ruben Ernst
Sep 19 '16 at 6:14
1
Would you (or @RubenErnst) mind expanding on the answer a bit? In particular, "the IPs listed on GCE must be the intrenal IP." Which IP do you mean? Are you able to get this working with a static IP assigned to your single node cluster?
– Brett
Apr 18 '17 at 0:02
@Brett: Sorry for my late response. Is your question already answered in the meantime?
– Ruben Ernst
Oct 19 '17 at 8:28
Thanks! But I think I missed something. The service is deployed but unable from the internet. I set the correct firewall rules. The service is displaying the correct
externalIp– Ruben Ernst
Sep 16 '16 at 15:28
Thanks! But I think I missed something. The service is deployed but unable from the internet. I set the correct firewall rules. The service is displaying the correct
externalIp– Ruben Ernst
Sep 16 '16 at 15:28
Sorry for late reply, forgot that I spent time on the exact same issue. The IPs listed need to be the internal IP, not external (At least on GCE).
– ConnorJC
Sep 18 '16 at 20:25
Sorry for late reply, forgot that I spent time on the exact same issue. The IPs listed need to be the internal IP, not external (At least on GCE).
– ConnorJC
Sep 18 '16 at 20:25
Thanks, that was the solution! Unfortunately I'm not allowed to upvote yet... I dropped this comment to let you know that this answer combined with the comment above (which was the key) solved my issue!
– Ruben Ernst
Sep 19 '16 at 6:14
Thanks, that was the solution! Unfortunately I'm not allowed to upvote yet... I dropped this comment to let you know that this answer combined with the comment above (which was the key) solved my issue!
– Ruben Ernst
Sep 19 '16 at 6:14
1
1
Would you (or @RubenErnst) mind expanding on the answer a bit? In particular, "the IPs listed on GCE must be the intrenal IP." Which IP do you mean? Are you able to get this working with a static IP assigned to your single node cluster?
– Brett
Apr 18 '17 at 0:02
Would you (or @RubenErnst) mind expanding on the answer a bit? In particular, "the IPs listed on GCE must be the intrenal IP." Which IP do you mean? Are you able to get this working with a static IP assigned to your single node cluster?
– Brett
Apr 18 '17 at 0:02
@Brett: Sorry for my late response. Is your question already answered in the meantime?
– Ruben Ernst
Oct 19 '17 at 8:28
@Brett: Sorry for my late response. Is your question already answered in the meantime?
– Ruben Ernst
Oct 19 '17 at 8:28
|
show 2 more comments
In addition to ConnorJC's great and working solution: The same solution is also described in this question:
Kubernetes - can I avoid using the GCE Load Balancer to reduce cost?
The "internalIp" refers to the compute instance's (a.k.a. the node's) internal ip (as seen on Google Cloud Platform -> Google Compute Engine -> VM Instances)
This comment gives a hint at why the internal and not the external ip should be configured.
Furthermore, after having configured the service for ports 80 and 443, I had to create a firewall rule allowing traffic to my instance node:
gcloud compute firewall-rules create your-name-for-this-fw-rule --allow tcp:80,tcp:443 --source-ranges=0.0.0.0/0
After this setup, I could access my service through http(s)://externalIp
Using the node internal IP did the trick. 👍 Such confusion with the naming!
– James
Feb 23 at 0:40
add a comment |
In addition to ConnorJC's great and working solution: The same solution is also described in this question:
Kubernetes - can I avoid using the GCE Load Balancer to reduce cost?
The "internalIp" refers to the compute instance's (a.k.a. the node's) internal ip (as seen on Google Cloud Platform -> Google Compute Engine -> VM Instances)
This comment gives a hint at why the internal and not the external ip should be configured.
Furthermore, after having configured the service for ports 80 and 443, I had to create a firewall rule allowing traffic to my instance node:
gcloud compute firewall-rules create your-name-for-this-fw-rule --allow tcp:80,tcp:443 --source-ranges=0.0.0.0/0
After this setup, I could access my service through http(s)://externalIp
Using the node internal IP did the trick. 👍 Such confusion with the naming!
– James
Feb 23 at 0:40
add a comment |
In addition to ConnorJC's great and working solution: The same solution is also described in this question:
Kubernetes - can I avoid using the GCE Load Balancer to reduce cost?
The "internalIp" refers to the compute instance's (a.k.a. the node's) internal ip (as seen on Google Cloud Platform -> Google Compute Engine -> VM Instances)
This comment gives a hint at why the internal and not the external ip should be configured.
Furthermore, after having configured the service for ports 80 and 443, I had to create a firewall rule allowing traffic to my instance node:
gcloud compute firewall-rules create your-name-for-this-fw-rule --allow tcp:80,tcp:443 --source-ranges=0.0.0.0/0
After this setup, I could access my service through http(s)://externalIp
In addition to ConnorJC's great and working solution: The same solution is also described in this question:
Kubernetes - can I avoid using the GCE Load Balancer to reduce cost?
The "internalIp" refers to the compute instance's (a.k.a. the node's) internal ip (as seen on Google Cloud Platform -> Google Compute Engine -> VM Instances)
This comment gives a hint at why the internal and not the external ip should be configured.
Furthermore, after having configured the service for ports 80 and 443, I had to create a firewall rule allowing traffic to my instance node:
gcloud compute firewall-rules create your-name-for-this-fw-rule --allow tcp:80,tcp:443 --source-ranges=0.0.0.0/0
After this setup, I could access my service through http(s)://externalIp
edited Jan 15 '18 at 9:26
Community♦
1
1
answered Jan 9 '18 at 21:05
derMikeyderMikey
312
312
Using the node internal IP did the trick. 👍 Such confusion with the naming!
– James
Feb 23 at 0:40
add a comment |
Using the node internal IP did the trick. 👍 Such confusion with the naming!
– James
Feb 23 at 0:40
Using the node internal IP did the trick. 👍 Such confusion with the naming!
– James
Feb 23 at 0:40
Using the node internal IP did the trick. 👍 Such confusion with the naming!
– James
Feb 23 at 0:40
add a comment |
If you only have exactly one pod, you can use hostNetwork: true to achieve this:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: caddy
spec:
replicas: 1
template:
metadata:
labels:
app: caddy
spec:
hostNetwork: true # <---------
containers:
- name: caddy
image: your_image
env:
- name: STATIC_BACKEND # example env in my custom image
value: $(STATIC_SERVICE_HOST):80
Note that by doing this your pod will inherit the host's DNS resolver and not Kubernetes'. That means you can no longer resolve cluster services by DNS name. For example, in the example above you cannot access the static service at http://static. You still can access services by their cluster IP, which are injected by environment variables.
This solution is better than using service's externalIP as it bypass kube-proxy, and you will receive the correct source IP.
add a comment |
If you only have exactly one pod, you can use hostNetwork: true to achieve this:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: caddy
spec:
replicas: 1
template:
metadata:
labels:
app: caddy
spec:
hostNetwork: true # <---------
containers:
- name: caddy
image: your_image
env:
- name: STATIC_BACKEND # example env in my custom image
value: $(STATIC_SERVICE_HOST):80
Note that by doing this your pod will inherit the host's DNS resolver and not Kubernetes'. That means you can no longer resolve cluster services by DNS name. For example, in the example above you cannot access the static service at http://static. You still can access services by their cluster IP, which are injected by environment variables.
This solution is better than using service's externalIP as it bypass kube-proxy, and you will receive the correct source IP.
add a comment |
If you only have exactly one pod, you can use hostNetwork: true to achieve this:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: caddy
spec:
replicas: 1
template:
metadata:
labels:
app: caddy
spec:
hostNetwork: true # <---------
containers:
- name: caddy
image: your_image
env:
- name: STATIC_BACKEND # example env in my custom image
value: $(STATIC_SERVICE_HOST):80
Note that by doing this your pod will inherit the host's DNS resolver and not Kubernetes'. That means you can no longer resolve cluster services by DNS name. For example, in the example above you cannot access the static service at http://static. You still can access services by their cluster IP, which are injected by environment variables.
This solution is better than using service's externalIP as it bypass kube-proxy, and you will receive the correct source IP.
If you only have exactly one pod, you can use hostNetwork: true to achieve this:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: caddy
spec:
replicas: 1
template:
metadata:
labels:
app: caddy
spec:
hostNetwork: true # <---------
containers:
- name: caddy
image: your_image
env:
- name: STATIC_BACKEND # example env in my custom image
value: $(STATIC_SERVICE_HOST):80
Note that by doing this your pod will inherit the host's DNS resolver and not Kubernetes'. That means you can no longer resolve cluster services by DNS name. For example, in the example above you cannot access the static service at http://static. You still can access services by their cluster IP, which are injected by environment variables.
This solution is better than using service's externalIP as it bypass kube-proxy, and you will receive the correct source IP.
answered Jul 20 '17 at 1:27
willwillwillwill
1112
1112
add a comment |
add a comment |
I prefer not to use the cloud load balancers, until necessary, because of cost and vendor lock-in.
Instead I use this: https://kubernetes.github.io/ingress-nginx/deploy/
It's a pod that runs a load balancer for you. That page has GKE specific installation notes.
add a comment |
I prefer not to use the cloud load balancers, until necessary, because of cost and vendor lock-in.
Instead I use this: https://kubernetes.github.io/ingress-nginx/deploy/
It's a pod that runs a load balancer for you. That page has GKE specific installation notes.
add a comment |
I prefer not to use the cloud load balancers, until necessary, because of cost and vendor lock-in.
Instead I use this: https://kubernetes.github.io/ingress-nginx/deploy/
It's a pod that runs a load balancer for you. That page has GKE specific installation notes.
I prefer not to use the cloud load balancers, until necessary, because of cost and vendor lock-in.
Instead I use this: https://kubernetes.github.io/ingress-nginx/deploy/
It's a pod that runs a load balancer for you. That page has GKE specific installation notes.
answered 48 mins ago
Michael ColeMichael Cole
226110
226110
add a comment |
add a comment |
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f801189%2fexpose-port-80-and-443-on-google-container-engine-without-load-balancer%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown