kubernetes horizontal pod autoscaler example
This commit is contained in:
22
k8s/deployment.yml
Normal file
22
k8s/deployment.yml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
apiVersion: extensions/v1beta1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: node-example
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: node-example
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: node-example
|
||||||
|
image: vamin2/node-example
|
||||||
|
imagePullPolicy: Always
|
||||||
|
ports:
|
||||||
|
- containerPort: 3000
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpu: "0.5"
|
||||||
|
requests:
|
||||||
|
cpu: "0.25"
|
||||||
14
k8s/hpa.yml
Normal file
14
k8s/hpa.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
apiVersion: autoscaling/v1
|
||||||
|
kind: HorizontalPodAutoscaler
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
name: node-example
|
||||||
|
namespace: default
|
||||||
|
spec:
|
||||||
|
maxReplicas: 4
|
||||||
|
minReplicas: 1
|
||||||
|
scaleTargetRef:
|
||||||
|
apiVersion: extensions/v1
|
||||||
|
kind: Deployment
|
||||||
|
name: node-example
|
||||||
|
targetCPUUtilizationPercentage: 1
|
||||||
14
k8s/service.yml
Normal file
14
k8s/service.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: node-example
|
||||||
|
labels:
|
||||||
|
app: node-example
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: node-example
|
||||||
|
ports:
|
||||||
|
- port: 3000
|
||||||
|
protocol: TCP
|
||||||
|
nodePort: 30001
|
||||||
|
type: LoadBalancer
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"start" : "node index.js"
|
"start" : "node src/index.js"
|
||||||
},
|
},
|
||||||
"author": "Vivek Amin",
|
"author": "Vivek Amin",
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const port = process.env.PORT || 3000;
|
|||||||
const server = http.createServer((req, res) => {
|
const server = http.createServer((req, res) => {
|
||||||
res.statusCode = 200;
|
res.statusCode = 200;
|
||||||
res.setHeader('Content-Type', 'text/plain');
|
res.setHeader('Content-Type', 'text/plain');
|
||||||
res.end('Hello World\n');
|
res.end('Hello World!!\n');
|
||||||
});
|
});
|
||||||
server.listen(port, () => {
|
server.listen(port, () => {
|
||||||
console.log(`Server running on port: ${port}`);
|
console.log(`Server running on port: ${port}`);
|
||||||
Reference in New Issue
Block a user