Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
en:modul:m321_aws:topics:08 [2025/10/22 15:53] dgaravaldien:modul:m321_aws:topics:08 [2025/10/22 16:32] (aktuell) dgaravaldi
Zeile 21: Zeile 21:
 It's recommend using YAML as the format for these declarations. You could use JSON, but YAML allows you __to add comments into the declarations__, which are immensely useful for others reading those files. It's recommend using YAML as the format for these declarations. You could use JSON, but YAML allows you __to add comments into the declarations__, which are immensely useful for others reading those files.
  
 +\\
 ==== Example 1: Deployment-Elements in YAML explained ==== ==== Example 1: Deployment-Elements in YAML explained ====
 <code> <code>
Zeile 45: Zeile 45:
         ports:                   (9)         ports:                   (9)
         - containerPort: 8080         - containerPort: 8080
- 
 </code> </code>
 +
 +
 In this YAML configuration, we have to ensure the following: In this YAML configuration, we have to ensure the following:
 \\ \\
Zeile 79: Zeile 80:
 $ kubectl logs pods/calculator-deployment-dccdf8756-h2l6c $ kubectl logs pods/calculator-deployment-dccdf8756-h2l6c
 </code> </code>
- 
  
 \\ \\
Zeile 145: Zeile 145:
       targetPort: 8080       targetPort: 8080
   type: ClusterIP   type: ClusterIP
 +</code>
 +\\
 +\\
 +===== Service types =====
 +As a recapture on how your application can be accessed from the outside, we need to start with the types of Kubernetes Services. You can use four different service types, as follows:
 +
 +  * ''ClusterIP (default)'': The service has an internal IP only.
 +  * ''NodePort'': Exposes the service on the same port of each cluster node. In other words, each physical machine (which is a Kubernetes node) opens a port that is forwarded to the service. Then, you can access it by using ''<NODE-IP>:<NODE-PORT>''.
 +  * ''LoadBalancer'': Creates an external load balancer and assigns a separate external IP for the service. Your Kubernetes cluster must support external load balancers, which works fine in the case of cloud platforms, but may not work if you use minikube.
 +  * ''ExternalName'': Exposes the service using a DNS name (specified by externalName in the spec).
 +
 +While LoadBalancer seems to be the simplest solution, it has two drawbacks:
 +  * It's not always available, for example, if you're using minikube.
 +  * External public IPs are usually expensive. A different solution is to use a ''NodePort'' service.
 +
 +<code>
 +$ kubectl get service my-python-service
 +NAME               TYPE     CLUSTER-IP    EXTERNAL-IP  PORT(S)        AGE
 +my-python-service  NodePort 10.19.248.154 <none>       8080:32259/TCP 13m
 +</code>
 +
 +You can see that port ''32259'' was selected as a node port. This means that we can access our ''my-python-service'' service using that port and the IP of any of the Kubernetes nodes.
 +
 +The IP address of your Kubernetes node depends on your installation. In the case of minikube, you can check it with the minikube ip command:
 +
 +<code>
 +$ kubectl get nodes -o jsonpath='{ $.items[*].status.addresses[?(@.type=="ExternalIP")].address }'
 +35.192.180.252 35.232.125.195 104.198.131.248
 +</code>
 +To check that you can access ''my-python-service'' from the outside, run the following command:
 +
 +<code>
 +$ curl http://<NODE-IP>:32047/
 </code> </code>
  
  • en/modul/m321_aws/topics/08.1761141202.txt.gz
  • Zuletzt geändert: 2025/10/22 15:53
  • von dgaravaldi