You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some parts of your application (e.g. frontends) you may want to expose a Service onto an external (outside of your cluster, maybe public internet) IP address, other services should be visible only from inside of the cluster.
421
+
422
+
Kubernetes ServiceTypes allow you to specify what kind of service you want. The default and base type is ClusterIP, which exposes a service to connection from inside the cluster. NodePort and LoadBalancer are two types that expose services to external traffic.
423
+
424
+
Valid values for the ServiceType field are:
425
+
426
+
- *ClusterIP*: use a cluster-internal IP only - this is the default and is discussed above. Choosing this value means that you want this service to be reachable only from inside of the cluster.
427
+
- *NodePort*: on top of having a cluster-internal IP, expose the service on a port on each node of the cluster (the same port on each node). You'll be able to contact the service on any <NodeIP>:NodePort address.
428
+
- *LoadBalancer*: on top of having a cluster-internal IP and exposing service on a NodePort also, ask the cloud provider for a load balancer which forwards to the Service exposed as a <NodeIP>:NodePort for each Node.
429
+
430
+
As you could see on <<Mysql_service_file>> section, the MySql service file doesn't contain any ServiceType field. For that reason, the default value is *ClusterIP* which means that the MySql service can be accessed inside the Cluster.
431
+
432
+
In the other hand, not all Kubernetes Provider supports the *LoadBalancer* type. On cloud providers which support external load balancers, setting the type field to "LoadBalancer" will provision a load balancer for your Service.
433
+
434
+
Do show how to access WildFly outside Kubernetes, we will need to use *NodePort* type which exposes your service on an external port on all nodes in your cluster.
You have exposed your service on an external port on all nodes in your
445
+
cluster. If you want to expose this service to the external internet, you may
446
+
need to set up firewall rules for the service port(s) (tcp:30140) to serve traffic.
447
+
448
+
See http://releases.k8s.io/HEAD/docs/user-guide/services-firewalls.md for more details.
449
+
services/wildfly-service
450
+
----
451
+
452
+
Note that it will reply with the port that was opened on each node of the cluster. Now you can use the combination between the node ip and the service port to access the service.
<h4 id="Access_Kubernetes_Application_Node">10.4.4. Access the application (using node)</h4>
3911
+
<h4 id="Access_Kubernetes_Application_Node">10.4.4. Access the application (from inside a node)</h4>
3912
3912
<div class="olist arabic">
3913
3913
<ol class="arabic">
3914
3914
<li>
@@ -3937,9 +3937,101 @@ <h4 id="Access_Kubernetes_Application_Node">10.4.4. Access the application (usin
3937
3937
</div>
3938
3938
</div>
3939
3939
<div class="sect3">
3940
-
<h4 id="Access_Kubernetes_Application_Proxy">10.4.5. Access the application (using proxy)</h4>
3940
+
<h4 id="Access_Kubernetes_Application_Service">10.4.5. Access the application (using Services)</h4>
3941
+
<div class="paragraph">
3942
+
<p>For some parts of your application (e.g. frontends) you may want to expose a Service onto an external (outside of your cluster, maybe public internet) IP address, other services should be visible only from inside of the cluster.</p>
3943
+
</div>
3944
+
<div class="paragraph">
3945
+
<p>Kubernetes ServiceTypes allow you to specify what kind of service you want. The default and base type is ClusterIP, which exposes a service to connection from inside the cluster. NodePort and LoadBalancer are two types that expose services to external traffic.</p>
3946
+
</div>
3947
+
<div class="paragraph">
3948
+
<p>Valid values for the ServiceType field are:</p>
3949
+
</div>
3950
+
<div class="ulist">
3951
+
<ul>
3952
+
<li>
3953
+
<p><strong>ClusterIP</strong>: use a cluster-internal IP only - this is the default and is discussed above. Choosing this value means that you want this service to be reachable only from inside of the cluster.</p>
3954
+
</li>
3955
+
<li>
3956
+
<p><strong>NodePort</strong>: on top of having a cluster-internal IP, expose the service on a port on each node of the cluster (the same port on each node). You’ll be able to contact the service on any <NodeIP>:NodePort address.</p>
3957
+
</li>
3958
+
<li>
3959
+
<p><strong>LoadBalancer</strong>: on top of having a cluster-internal IP and exposing service on a NodePort also, ask the cloud provider for a load balancer which forwards to the Service exposed as a <NodeIP>:NodePort for each Node.</p>
3960
+
</li>
3961
+
</ul>
3962
+
</div>
3963
+
<div class="paragraph">
3964
+
<p>As you could see on <a href="#Mysql_service_file">Start MySQL service</a> section, the MySql service file doesn’t contain any ServiceType field. For that reason, the default value is <strong>ClusterIP</strong> which means that the MySql service can be accessed inside the Cluster.</p>
3965
+
</div>
3966
+
<div class="paragraph">
3967
+
<p>In the other hand, not all Kubernetes Provider supports the <strong>LoadBalancer</strong> type. On cloud providers which support external load balancers, setting the type field to "LoadBalancer" will provision a load balancer for your Service.</p>
3968
+
</div>
3969
+
<div class="paragraph">
3970
+
<p>Do show how to access WildFly outside Kubernetes, we will need to use <strong>NodePort</strong> type which exposes your service on an external port on all nodes in your cluster.</p>
You have exposed your service on an external port on all nodes in your
3986
+
cluster. If you want to expose this service to the external internet, you may
3987
+
need to set up firewall rules for the service port(s) (tcp:30140) to serve traffic.
3988
+
3989
+
See http://releases.k8s.io/HEAD/docs/user-guide/services-firewalls.md for more details.
3990
+
services/wildfly-service</code></pre>
3991
+
</div>
3992
+
</div>
3993
+
<div class="paragraph">
3994
+
<p>Note that it will reply with the port that was opened on each node of the cluster. Now you can use the combination between the node ip and the service port to access the service.</p>
3995
+
</div>
3996
+
<div class="olist arabic">
3997
+
<ol class="arabic">
3998
+
<li>
3999
+
<p>Get the IP of the node</p>
4000
+
</li>
4001
+
</ol>
4002
+
</div>
4003
+
<div class="listingblock">
4004
+
<div class="content">
4005
+
<pre class="CodeRay highlight"><code data-lang="text">cluster/kubectl.sh get nodes
<pre class="CodeRay highlight"><code data-lang="text">cluster/kubectl.sh describe se wildfly-service
4020
+
Name: wildfly-service
4021
+
Namespace: default
4022
+
Labels: context=docker-k8s-lab,name=wildfly
4023
+
Selector: context=docker-k8s-lab,name=wildfly
4024
+
Type: NodePort
4025
+
IP: 10.247.39.239
4026
+
Port: <unnamed> 8080/TCP
4027
+
NodePort: <unnamed> 30140/TCP
4028
+
Endpoints: 10.246.88.7:8080
4029
+
Session Affinity: None
4030
+
No events.</code></pre>
4031
+
</div>
4032
+
</div>
3941
4033
<div class="paragraph">
3942
-
<p>Send a PR for <a href="https://github.com/javaee-samples/docker-java/issues/80" class="bare">https://github.com/javaee-samples/docker-java/issues/80</a></p>
4034
+
<p>Note the <em>NodePort</em> value and now you can access the URL: <a href="http://10.245.1.3:30140/employees/" class="bare">http://10.245.1.3:30140/employees/</a></p>
3943
4035
</div>
3944
4036
</div>
3945
4037
</div>
@@ -4018,6 +4110,7 @@ <h3 id="_deploy_java_ee_application_one_configuration_file">10.5. Deploy Java EE
@@ -4047,7 +4140,7 @@ <h3 id="_deploy_java_ee_application_one_configuration_file">10.5. Deploy Java EE
4047
4140
<div class="olist arabic">
4048
4141
<ol class="arabic">
4049
4142
<li>
4050
-
<p>Access the application using <a href="#Access_Kubernetes_Application_Node">Access the application (using node)</a> or <a href="#Access_Kubernetes_Application_Proxy">Access the application (using proxy)</a>.</p>
4143
+
<p>Access the application using <a href="#Access_Kubernetes_Application_Node">Access the application (from inside a node)</a> or <a href="#Access_Kubernetes_Application_Service">Access the application (using Services)</a>.</p>
0 commit comments