-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
184 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ metadata: | |
labels: | ||
app: hello-world | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- port: 80 | ||
targetPort: 8080 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ kind: Service | |
metadata: | ||
name: svc-sidecar | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app: sidecar | ||
ports: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: svc-test | ||
spec: | ||
replicas: 10 | ||
selector: | ||
matchLabels: | ||
chapter: services | ||
template: | ||
metadata: | ||
labels: | ||
chapter: services | ||
spec: | ||
containers: | ||
- name: hello-ctr | ||
image: nigelpoulton/k8sbook:1.0 | ||
ports: | ||
- containerPort: 8080 | ||
# --- | ||
# apiVersion: v1 | ||
# kind: Service | ||
# metadata: | ||
# name: svc-test | ||
# labels: | ||
# chapter: services | ||
# spec: | ||
# ipFamilyPolicy: PreferDualStack | ||
# ipFamilies: | ||
# - IPv4 | ||
# - IPv6 | ||
# type: NodePort | ||
# ports: | ||
# - port: 8080 | ||
# nodePort: 30001 | ||
# targetPort: 9090 | ||
# protocol: TCP | ||
# selector: | ||
# chapter: services | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: cloud-lb | ||
spec: | ||
type: LoadBalancer | ||
ports: | ||
- port: 9000 | ||
targetPort: 8080 | ||
selector: | ||
chapter: services |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
Kubernetes has several types of Services for different use cases and requirements. The major ones are: | ||
|
||
- ClusterIP | ||
- NodePort | ||
- LoadBalance | ||
|
||
![nodeort](../public/09_nodeport_services.png) | ||
|
||
![lb](../public/10_lb_services.png) | ||
|
||
```bash | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: svc-test | ||
spec: | ||
replicas: 10 | ||
selector: | ||
matchLabels: | ||
chapter: services | ||
template: | ||
metadata: | ||
labels: | ||
chapter: services | ||
spec: | ||
containers: | ||
- name: hello-ctr | ||
image: nigelpoulton/k8sbook:1.0 | ||
ports: | ||
- containerPort: 8080 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: cloud-lb | ||
spec: | ||
type: LoadBalancer | ||
ports: | ||
- port: 9000 | ||
targetPort: 8080 | ||
selector: | ||
chapter: services | ||
``` | ||
|
||
```bash | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: svc-test | ||
labels: | ||
chapter: services | ||
spec: | ||
ipFamilyPolicy: PreferDualStack | ||
ipFamilies: | ||
- IPv4 | ||
- IPv6 | ||
type: NodePort | ||
ports: | ||
- port: 8080 | ||
nodePort: 30001 | ||
targetPort: 9090 | ||
protocol: TCP | ||
selector: | ||
chapter: services | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Services use labels and selectors to know which Pods to send traffic to. This is the same technology that loosely couples Deployments to Pods. | ||
|
||
![services_labels](../public/08_services_labels.png) | ||
|
||
You create a Service, and the EndpointSlice controller automatically creates an associated | ||
EndpointSlice object. Kubernetes then watches the cluster, looking for Pods matching | ||
the Service’s label selector. Any new Pods matching the selector are added to the | ||
EndpointSlice, whereas any deleted Pods get removed. Applications send traffic to the | ||
Service name, and the application’s container uses the cluster DNS to resolve the name | ||
to an IP address. The container then sends the traffic to the Service’s IP, and the Service | ||
forwards it to one of the Pods listed in the EndpointSlice. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters