Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

Commit 1d78ece

Browse files
authored
Adding nodejs kubernetes flow-> Default and With DB (#265)
* Add php support, update tweet links on python * Adding kubernetes flow for GitHub * Add kubernetes with db flow * Add plain node kubernetes flow * Add new control for api version * Add fix for api version in node plain kube
1 parent 3271915 commit 1d78ece

File tree

136 files changed

+28244
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+28244
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.swp
2+
*.tmp
3+
*.temp
4+
.git*
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM node:8
2+
LABEL maintainer="Azure App Services Container Images <[email protected]>"
3+
4+
ENV PORT 8080
5+
EXPOSE 8080
6+
7+
# Create app directory
8+
WORKDIR /app
9+
COPY package.json .
10+
11+
# Install app dependencies
12+
RUN npm install
13+
14+
# Bundle app source
15+
COPY . .
16+
17+
CMD ["npm", "start"]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Microsoft Corporation. All rights reserved.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
| Language | Framework | Platform | Author |
2+
| -------- | -------- |--------|--------|
3+
| Nodejs | Express | Azure Web App, Virtual Machine| |
4+
5+
6+
# Nodejs Express web application
7+
8+
Sample Nodejs Express web application built using Visual Studio 2017.
9+
10+
## License:
11+
12+
See [LICENSE](LICENSE).
13+
14+
## Contributing
15+
16+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
17+
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
'use strict';
2+
var debug = require('debug');
3+
var express = require('express');
4+
var path = require('path');
5+
var favicon = require('serve-favicon');
6+
var logger = require('morgan');
7+
var cookieParser = require('cookie-parser');
8+
var bodyParser = require('body-parser');
9+
var routes = require('./routes/index');
10+
var users = require('./routes/users');
11+
var redis = require('ioredis');
12+
var redisServer = process.env.redis_server || 'redis-cache';
13+
14+
var appInsights = require('applicationinsights');
15+
appInsights.setup();
16+
appInsights.start();
17+
18+
var app = express();
19+
var client = redis.createClient(6379, redisServer);
20+
21+
// view engine setup
22+
app.set('views', path.join(__dirname, 'views'));
23+
app.set('view engine', 'pug');
24+
25+
// uncomment after placing your favicon in /public
26+
//app.use(favicon(__dirname + '/public/favicon.ico'));
27+
app.use(logger('dev'));
28+
app.use(bodyParser.json());
29+
app.use(bodyParser.urlencoded({ extended: false }));
30+
app.use(cookieParser());
31+
app.use(express.static(path.join(__dirname, 'public')));
32+
33+
app.use('/', routes);
34+
app.use('/users', users);
35+
36+
// catch 404 and forward to error handler
37+
app.use(function (req, res, next) {
38+
var err = new Error('Not Found');
39+
err.status = 404;
40+
next(err);
41+
});
42+
43+
// error handlers
44+
// development error handler
45+
// will print stacktrace
46+
if (app.get('env') === 'development') {
47+
app.use(function (err, req, res, next) {
48+
res.status(err.status || 500);
49+
res.render('error', {
50+
message: err.message,
51+
error: err
52+
});
53+
});
54+
}
55+
56+
// production error handler
57+
// no stacktraces leaked to user
58+
app.use(function (err, req, res, next) {
59+
res.status(err.status || 500);
60+
res.render('error', {
61+
message: err.message,
62+
error: {}
63+
});
64+
});
65+
66+
app.set('port', process.env.PORT || 8080);
67+
68+
var server = app.listen(app.get('port'), function () {
69+
client.exists('viewCount',function(err,reply) {
70+
if(!err) {
71+
if(reply === 1) {
72+
debug("Key exists");
73+
} else {
74+
client.set('viewCount', 0)
75+
}
76+
}
77+
});
78+
debug('Express server listening on port ' + server.address().port);
79+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
description: A Helm chart for Kubernetes
3+
name: sampleapp
4+
version: v0.2.0
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $.Values.ingress.hostname }}{{ $.Values.ingress.path }}
4+
{{- else }}
5+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
6+
You can watch the status of by running 'kubectl get svc -w {{ template "sampleapp.fullname" . }}'
7+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "sampleapp.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
8+
echo http://$SERVICE_IP:{{ .Values.service.port }}
9+
{{- end }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "sampleapp.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "sampleapp.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "sampleapp.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
apiVersion: {{ .Values.apiVersion }}
2+
kind: Deployment
3+
metadata:
4+
name: {{ template "sampleapp.fullname" . }}
5+
labels:
6+
app: {{ template "sampleapp.name" . }}
7+
chart: {{ template "sampleapp.chart" . }}
8+
release: {{ .Release.Name }}
9+
heritage: {{ .Release.Service }}
10+
spec:
11+
replicas: {{ .Values.replicaCount }}
12+
selector:
13+
matchLabels:
14+
app: {{ template "sampleapp.name" . }}
15+
release: {{ .Release.Name }}
16+
template:
17+
metadata:
18+
labels:
19+
app: {{ template "sampleapp.name" . }}
20+
release: {{ .Release.Name }}
21+
spec:
22+
containers:
23+
- name: {{ .Chart.Name }}
24+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
25+
imagePullPolicy: {{ .Values.image.pullPolicy }}
26+
ports:
27+
- name: http
28+
containerPort: {{ .Values.service.port }}
29+
protocol: TCP
30+
livenessProbe:
31+
httpGet:
32+
path: /
33+
port: http
34+
initialDelaySeconds: 30
35+
readinessProbe:
36+
httpGet:
37+
path: /
38+
port: http
39+
initialDelaySeconds: 30
40+
env:
41+
- name: APPINSIGHTS_INSTRUMENTATIONKEY
42+
value: {{ .Values.applicationInsights.InstrumentationKey }}
43+
{{- $root := . }}
44+
{{- range $ref, $values := .Values.secrets }}
45+
{{- range $key, $value := $values }}
46+
- name: {{ $ref | upper }}_{{ $key | upper }}
47+
valueFrom:
48+
secretKeyRef:
49+
name: {{ template "sampleapp.fullname" $root }}-{{ $ref }}
50+
key: {{ $key }}
51+
{{- end }}
52+
{{- end }}
53+
resources:
54+
{{ toYaml .Values.resources | indent 12 }}
55+
{{- if .Values.imagePullSecrets }}
56+
imagePullSecrets:
57+
{{- range .Values.imagePullSecrets }}
58+
- name: {{ . }}
59+
{{- end}}
60+
{{- end }}
61+
{{- with .Values.nodeSelector }}
62+
nodeSelector:
63+
{{ toYaml . | indent 8 }}
64+
{{- end }}
65+
{{- with .Values.affinity }}
66+
affinity:
67+
{{ toYaml . | indent 8 }}
68+
{{- end }}
69+
{{- with .Values.tolerations }}
70+
tolerations:
71+
{{ toYaml . | indent 8 }}
72+
{{- end }}

0 commit comments

Comments
 (0)