Skip to content

Commit a076413

Browse files
Kalyan Reddy DaidaKalyan Reddy Daida
authored andcommitted
Welcome to Stack Simplify
1 parent 125de56 commit a076413

12 files changed

+139
-77
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: myapp-pod-nodeport-service
5+
spec:
6+
type: NodePort
7+
selector:
8+
app: myapp
9+
ports:
10+
- name: http
11+
port: 80 # Service Port
12+
targetPort: 80 # Container Port
13+
nodePort: 31231 # NodePort

08-ReplicaSets-with-YAML/02-replicaset-base-template.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

08-ReplicaSets-with-YAML/03-replicaset-definition.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

08-ReplicaSets-with-YAML/04-replicaset-nodeport-service.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

08-ReplicaSets-with-YAML/README.md

Lines changed: 60 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,77 @@
11
# ReplicaSets with YAML
22

3-
## Step-01: Understand Labels & Selectors
4-
- Discuss about Labels and Selectors
5-
6-
## Step-02: Create ReplicaSet
7-
- Create ReplicaSet with 3 Replicas
8-
- Verify pod names, one pod which we created using `pod-definition.yml` will be part of replicaset because it also has `labels: app=myapp`
9-
```
10-
kubectl apply -f replicaset-definition.yml
11-
kubectl get rs
12-
kubectl get pods
13-
```
14-
- Delete the pod which we created using `pod-definition.yml`
15-
- ReplicaSet immediately creates the pod.
16-
```
17-
kubectl delete pod myapp-pod
18-
kubectl get pods
19-
```
3+
## Step-01: Create ReplicaSet Definition
204
- **replicaset-definition.yml**
215
```yml
226
apiVersion: apps/v1
237
kind: ReplicaSet
248
metadata:
25-
name: myapp-rs
9+
name: myapp2-rs
2610
spec:
27-
replicas: 3
28-
selector:
11+
replicas: 3 # 3 Pods should exist at all times.
12+
selector: # Pods label should be defined in ReplicaSet label selector
2913
matchLabels:
30-
app: myapp
14+
app: myapp2
3115
template:
3216
metadata:
33-
name: myapp-pod
17+
name: myapp2-pod
3418
labels:
35-
app: myapp
19+
app: myapp2 # Atleast 1 Pod label should match with ReplicaSet Label Selector
3620
spec:
3721
containers:
38-
- name: myapp
22+
- name: myapp2
3923
image: stacksimplify/kubenginx:2.0.0
4024
ports:
4125
- containerPort: 80
42-
```
26+
```
27+
## Step-02: Create ReplicaSet
28+
- Create ReplicaSet with 3 Replicas
29+
```
30+
# Create ReplicaSet
31+
kubectl apply -f 02-replicaset-definition.yml
32+
33+
# List Replicasets
34+
kubectl get rs
35+
```
36+
- Delete a pod
37+
- ReplicaSet immediately creates the pod.
38+
```
39+
# List Pods
40+
kubectl get pods
41+
42+
# Delete Pod
43+
kubectl delete pod <Pod-Name>
44+
```
45+
46+
## Step-03: Create NodePort Service for ReplicaSet
47+
```yml
48+
apiVersion: v1
49+
kind: Service
50+
metadata:
51+
name: replicaset-nodeport-service
52+
spec:
53+
type: NodePort
54+
selector:
55+
app: myapp2
56+
ports:
57+
- name: http
58+
port: 80
59+
targetPort: 80
60+
nodePort: 31232
61+
```
62+
- Create NodePort Service for ReplicaSet & Test
63+
```
64+
# Create NodePort Service
65+
kubectl apply -f 03-replicaset-nodeport-servie.yml
66+
67+
# List NodePort Service
68+
kubectl get svc
69+
70+
# Get Public IP
71+
kubectl get nodes -o wide
72+
73+
# Access Application
74+
http://<Worker-Node-Public-IP>:<NodePort>
75+
http://<Worker-Node-Public-IP>:31232
76+
77+
```
File renamed without changes.

08-ReplicaSets-with-YAML/kube-manifests/02-replicaset-definition.yml

Whitespace-only changes.

08-ReplicaSets-with-YAML/kube-manifests/03-replicaset-nodeport-servie.yml

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion:
2+
kind:
3+
metadata:
4+
5+
spec:
6+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: apps/v1
2+
kind: ReplicaSet
3+
metadata:
4+
name: myapp2-rs
5+
spec:
6+
replicas: 3 # 3 Pods should exist at all times.
7+
selector: # Pods label should be defined in ReplicaSet label selector
8+
matchLabels:
9+
app: myapp2
10+
template:
11+
metadata:
12+
name: myapp2-pod
13+
labels:
14+
app: myapp2 # Atleast 1 Pod label should match with ReplicaSet Label Selector
15+
spec:
16+
containers:
17+
- name: myapp2
18+
image: stacksimplify/kubenginx:2.0.0
19+
ports:
20+
- containerPort: 80

0 commit comments

Comments
 (0)