This repository was archived by the owner on Oct 11, 2023. It is now read-only.
File tree 14 files changed +340
-0
lines changed
samples/python/getting-started/webfrontend
14 files changed +340
-0
lines changed Original file line number Diff line number Diff line change
1
+ FROM python:3
2
+
3
+ WORKDIR /python/webfrontend
4
+
5
+ RUN pip install flask
6
+
7
+ COPY webfrontend.py webfrontend.py
8
+ COPY public/ public/
9
+
10
+ EXPOSE 80
11
+ CMD ["python" , "./webfrontend.py" ]
Original file line number Diff line number Diff line change
1
+ /* Copyright (c) Microsoft Corporation. All rights reserved.
2
+ Licensed under the MIT License. */
3
+
4
+ .message {
5
+ font-family : Courier New, Courier, monospace;
6
+ font-weight : bold;
7
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ var app = angular . module ( 'myApp' , [ 'ngRoute' ] ) ;
5
+
6
+ app . controller ( 'MainController' , function ( $scope , $http ) {
7
+
8
+ $scope . messages = [ ] ;
9
+ $scope . sayHelloToServer = function ( ) {
10
+ $http . get ( "/api?_=" + Date . now ( ) ) . then ( function ( response ) {
11
+ $scope . messages . push ( response . data ) ;
12
+ } ) ;
13
+ } ;
14
+
15
+ $scope . sayHelloToServer ( ) ;
16
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <!-- Copyright (c) Microsoft Corporation. All rights reserved.
2
+ Licensed under the MIT License. -->
3
+
4
+ <!doctype html>
5
+ < html ng-app ="myApp ">
6
+ < head >
7
+ < script src ="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js "> </ script >
8
+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.3/angular-route.js "> </ script >
9
+ < script src ="/public/app.js "> </ script >
10
+ < link rel ="stylesheet " href ="/public/app.css ">
11
+ < link href ="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css " rel ="stylesheet " integrity ="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7 " crossorigin ="anonymous ">
12
+ <!-- Uncomment the next line -->
13
+ <!-- <meta name="viewport" content="width=device-width, initial-scale=1"> -->
14
+ </ head >
15
+ < body style ="margin-left:10px; margin-right:10px; ">
16
+ < div ng-controller ="MainController ">
17
+ < h2 > Server Says</ h2 >
18
+ < div class ="row ">
19
+ < div class ="col-xs-8 col-md-10 ">
20
+ < div ng-repeat ="message in messages track by $index ">
21
+ < span class ="message "> {{message}}</ span >
22
+ </ div >
23
+ </ div >
24
+ < div class ="col-xs-4 col-md-2 ">
25
+ < button class ="btn btn-primary " ng-click ="sayHelloToServer() "> Say It Again</ button >
26
+ </ div >
27
+ </ div >
28
+ </ div >
29
+ </ body >
30
+ </ html >
Original file line number Diff line number Diff line change
1
+ // Copyright (c ) Microsoft Corporation . All rights reserved .
2
+ // Licensed under the MIT License .
3
+
4
+ from flask import Flask , request , send_from_directory
5
+ app = Flask (__name__ , static_url_path = '' )
6
+
7
+ @app .route ('/public/<path:path>' )
8
+ def static_files (path ):
9
+ return send_from_directory ('public' , path )
10
+
11
+ @app .route ('/api' )
12
+ def api ():
13
+ return 'Hello from webfrontend'
14
+
15
+ @app .route ('/' )
16
+ def index ():
17
+ return send_from_directory ('public' , 'index.html' )
18
+
19
+ if __name__ == '__main__' :
20
+ app .run (host = '0.0.0.0' , port = 80 )
Original file line number Diff line number Diff line change
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
22
+ .vscode/
Original file line number Diff line number Diff line change
1
+ apiVersion : v1
2
+ appVersion : " 1.0"
3
+ description : A Helm chart for Kubernetes
4
+ name : webfrontend
5
+ version : 0.1.0
Original file line number Diff line number Diff line change
1
+ 1. Get the application URL by running these commands:
2
+ {{- if .Values.ingress.enabled }}
3
+ {{- range $host := .Values.ingress.hosts }}
4
+ {{- range $.Values.ingress.paths }}
5
+ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ . }}
6
+ {{- end }}
7
+ {{- end }}
8
+ {{- else if contains "NodePort" .Values.service.type }}
9
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "webfrontend.fullname" . }})
10
+ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11
+ echo http://$NODE_IP:$NODE_PORT
12
+ {{- else if contains "LoadBalancer" .Values.service.type }}
13
+ NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14
+ You can watch the status of by running 'kubectl get svc -w {{ include "webfrontend.fullname" . }}'
15
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "webfrontend.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
16
+ echo http://$SERVICE_IP:{{ .Values.service.port }}
17
+ {{- else if contains "ClusterIP" .Values.service.type }}
18
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "webfrontend.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19
+ echo "Visit http://127.0.0.1:8080 to use your application"
20
+ kubectl port-forward $POD_NAME 8080:80
21
+ {{- end }}
Original file line number Diff line number Diff line change
1
+ { {/* vim: set filetype= mustache: */} }
2
+ { {/*
3
+ Expand the name of the chart.
4
+ */} }
5
+ { {- define " webfrontend.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 " webfrontend.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 " webfrontend.chart" -} }
31
+ { {- printf " %s-%s" .Chart.Name .Chart.Version | replace " +" " _" | trunc 63 | trimSuffix " -" -} }
32
+ { {- end -} }
Original file line number Diff line number Diff line change
1
+ apiVersion : apps/v1
2
+ kind : Deployment
3
+ metadata :
4
+ name : {{ include "webfrontend.fullname" . }}
5
+ labels :
6
+ app.kubernetes.io/name : {{ include "webfrontend.name" . }}
7
+ helm.sh/chart : {{ include "webfrontend.chart" . }}
8
+ app.kubernetes.io/instance : {{ .Release.Name }}
9
+ app.kubernetes.io/managed-by : {{ .Release.Service }}
10
+ spec :
11
+ replicas : {{ .Values.replicaCount }}
12
+ selector :
13
+ matchLabels :
14
+ app.kubernetes.io/name : {{ include "webfrontend.name" . }}
15
+ app.kubernetes.io/instance : {{ .Release.Name }}
16
+ template :
17
+ metadata :
18
+ labels :
19
+ app.kubernetes.io/name : {{ include "webfrontend.name" . }}
20
+ app.kubernetes.io/instance : {{ .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 : 80
29
+ protocol : TCP
30
+ livenessProbe :
31
+ httpGet :
32
+ path : /
33
+ port : http
34
+ readinessProbe :
35
+ httpGet :
36
+ path : /
37
+ port : http
38
+ resources :
39
+ {{- toYaml .Values.resources | nindent 12 }}
40
+ {{- with .Values.nodeSelector }}
41
+ nodeSelector :
42
+ {{- toYaml . | nindent 8 }}
43
+ {{- end }}
44
+ {{- with .Values.affinity }}
45
+ affinity :
46
+ {{- toYaml . | nindent 8 }}
47
+ {{- end }}
48
+ {{- with .Values.tolerations }}
49
+ tolerations :
50
+ {{- toYaml . | nindent 8 }}
51
+ {{- end }}
Original file line number Diff line number Diff line change
1
+ {{- if .Values.ingress.enabled -}}
2
+ {{- $fullName := include "webfrontend.fullname" . -}}
3
+ {{- $ingressPaths := .Values.ingress.paths -}}
4
+ apiVersion : extensions/v1beta1
5
+ kind : Ingress
6
+ metadata :
7
+ name : {{ $fullName }}
8
+ labels :
9
+ app.kubernetes.io/name : {{ include "webfrontend.name" . }}
10
+ helm.sh/chart : {{ include "webfrontend.chart" . }}
11
+ app.kubernetes.io/instance : {{ .Release.Name }}
12
+ app.kubernetes.io/managed-by : {{ .Release.Service }}
13
+ {{- with .Values.ingress.annotations }}
14
+ annotations :
15
+ {{- toYaml . | nindent 4 }}
16
+ {{- end }}
17
+ spec :
18
+ {{- if .Values.ingress.tls }}
19
+ tls :
20
+ {{- range .Values.ingress.tls }}
21
+ - hosts :
22
+ {{- range .hosts }}
23
+ - {{ . | quote }}
24
+ {{- end }}
25
+ secretName : {{ .secretName }}
26
+ {{- end }}
27
+ {{- end }}
28
+ rules :
29
+ {{- range .Values.ingress.hosts }}
30
+ - host : {{ . | quote }}
31
+ http :
32
+ paths :
33
+ {{- range $ingressPaths }}
34
+ - path : {{ . }}
35
+ backend :
36
+ serviceName : {{ $fullName }}
37
+ servicePort : http
38
+ {{- end }}
39
+ {{- end }}
40
+ {{- end }}
Original file line number Diff line number Diff line change
1
+ apiVersion : v1
2
+ kind : Service
3
+ metadata :
4
+ name : {{ include "webfrontend.fullname" . }}
5
+ labels :
6
+ app.kubernetes.io/name : {{ include "webfrontend.name" . }}
7
+ helm.sh/chart : {{ include "webfrontend.chart" . }}
8
+ app.kubernetes.io/instance : {{ .Release.Name }}
9
+ app.kubernetes.io/managed-by : {{ .Release.Service }}
10
+ spec :
11
+ type : {{ .Values.service.type }}
12
+ ports :
13
+ - port : {{ .Values.service.port }}
14
+ targetPort : http
15
+ protocol : TCP
16
+ name : http
17
+ selector :
18
+ app.kubernetes.io/name : {{ include "webfrontend.name" . }}
19
+ app.kubernetes.io/instance : {{ .Release.Name }}
Original file line number Diff line number Diff line change
1
+ apiVersion : v1
2
+ kind : Pod
3
+ metadata :
4
+ name : " {{ include " webfrontend.fullname" . }}-test-connection"
5
+ labels :
6
+ app.kubernetes.io/name : {{ include "webfrontend.name" . }}
7
+ helm.sh/chart : {{ include "webfrontend.chart" . }}
8
+ app.kubernetes.io/instance : {{ .Release.Name }}
9
+ app.kubernetes.io/managed-by : {{ .Release.Service }}
10
+ annotations :
11
+ " helm.sh/hook " : test-success
12
+ spec :
13
+ containers :
14
+ - name : wget
15
+ image : busybox
16
+ command : ['wget']
17
+ args : ['{{ include "webfrontend.fullname" . }}:{{ .Values.service.port }}']
18
+ restartPolicy : Never
Original file line number Diff line number Diff line change
1
+ # Default values for webfrontend.
2
+ # This is a YAML-formatted file.
3
+ # Declare variables to be passed into your templates.
4
+
5
+ replicaCount : 1
6
+
7
+ image :
8
+ repository : azds-webfrontend-python
9
+ tag : stable
10
+ pullPolicy : IfNotPresent
11
+
12
+ nameOverride : " "
13
+ fullnameOverride : " "
14
+
15
+ service :
16
+ type : LoadBalancer
17
+ port : 80
18
+
19
+ ingress :
20
+ enabled : true
21
+ annotations : {}
22
+ # kubernetes.io/ingress.class: nginx
23
+ # kubernetes.io/tls-acme: "true"
24
+ paths : ["/"]
25
+ hosts :
26
+ - webfrontend.local
27
+ tls : []
28
+ # - secretName: chart-example-tls
29
+ # hosts:
30
+ # - chart-example.local
31
+
32
+ resources : {}
33
+ # We usually recommend not to specify default resources and to leave this as a conscious
34
+ # choice for the user. This also increases chances charts run on environments with little
35
+ # resources, such as Minikube. If you do want to specify resources, uncomment the following
36
+ # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
37
+ # limits:
38
+ # cpu: 100m
39
+ # memory: 128Mi
40
+ # requests:
41
+ # cpu: 100m
42
+ # memory: 128Mi
43
+
44
+ nodeSelector : {}
45
+
46
+ tolerations : []
47
+
48
+ affinity : {}
You can’t perform that action at this time.
0 commit comments