-
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
0 parents
commit 217d6ca
Showing
6 changed files
with
104 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Deploy to Minikube using GitHub Actions | ||
|
||
on: [push] | ||
|
||
jobs: | ||
job1: | ||
runs-on: ubuntu-latest | ||
name: build Node.js Docker Image and deploy to minikube | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Start minikube | ||
uses: medyagh/setup-minikube@master | ||
- name: Try the cluster ! | ||
run: kubectl get pods -A | ||
- name: Build image | ||
run: | | ||
export SHELL=/bin/bash | ||
eval $(minikube -p minikube docker-env) | ||
docker build -f ./Dockerfile -t devopshint/node-app:latest . | ||
echo -n "verifying images:" | ||
docker images | ||
- name: Deploy to minikube | ||
run: | ||
kubectl apply -f k8s-node-app.yaml | ||
- name: Test service URLs | ||
run: | | ||
minikube service list | ||
minikube service nodejs-app --url |
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,8 @@ | ||
FROM node:14 | ||
WORKDIR /usr/src/app | ||
COPY package*.json ./ | ||
RUN npm install | ||
RUN npm install express | ||
COPY . . | ||
EXPOSE 3000 | ||
CMD [ "node", "server.js" ] |
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,2 @@ | ||
# deploy-to-minikube-using-github-actions | ||
Deploy to Minikube using GitHub Actions |
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,37 @@ | ||
--- | ||
kind: Deployment | ||
apiVersion: apps/v1 | ||
metadata: | ||
name: nodejs-app | ||
namespace: default | ||
labels: | ||
app: nodejs-app | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: nodejs-app | ||
template: | ||
metadata: | ||
labels: | ||
app: nodejs-app | ||
spec: | ||
containers: | ||
- name: nodejs-app | ||
image: "devopshint/node-app:latest" | ||
ports: | ||
- containerPort: 3000 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: nodejs-app | ||
namespace: default | ||
spec: | ||
selector: | ||
app: nodejs-app | ||
type: NodePort | ||
ports: | ||
- name: http | ||
targetPort: 3000 | ||
port: 80 |
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,13 @@ | ||
{ | ||
"name": "docker_web_app", | ||
"version": "1.0.0", | ||
"description": "Node.js on Docker", | ||
"author": "First Last <first.last@example.com>", | ||
"main": "server.js", | ||
"scripts": { | ||
"start": "node server.js" | ||
}, | ||
"dependencies": { | ||
"express": "^4.16.1" | ||
} | ||
} |
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,16 @@ | ||
'use strict'; | ||
|
||
const express = require('express'); | ||
|
||
// Constants | ||
const PORT = 3000; | ||
const HOST = '0.0.0.0'; | ||
|
||
// App | ||
const app = express(); | ||
app.get('/', (req, res) => { | ||
res.send('Hello World'); | ||
}); | ||
|
||
app.listen(PORT, HOST); | ||
console.log(`Running on http://${HOST}:${PORT}`); |