Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 4072c0c

Browse files
author
Robert Raboud
committed
Merge remote-tracking branch 'upstream/dev' into dev
2 parents f7dda83 + 4615188 commit 4072c0c

14 files changed

+287
-125
lines changed

k8s/deploy-ingress-azure.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kubectl patch deployment -n ingress-nginx nginx-ingress-controller --type=json --patch="$(cat nginx-ingress\publish-service-patch.yaml)"
2+
kubectl apply -f nginx-ingress\azure\service.yaml
3+
kubectl apply -f nginx-ingress\patch-service-without-rbac.yaml

k8s/deploy-ingress.ps1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
kubectl apply -f ingress.yaml
2+
3+
# Deploy nginx-ingress core files
4+
kubectl apply -f nginx-ingress\namespace.yaml
5+
kubectl apply -f nginx-ingress\default-backend.yaml
6+
kubectl apply -f nginx-ingress\configmap.yaml
7+
kubectl apply -f nginx-ingress\tcp-services-configmap.yaml
8+
kubectl apply -f nginx-ingress\udp-services-configmap.yaml
9+
kubectl apply -f nginx-ingress\without-rbac.yaml
10+
11+
12+

k8s/deploy.ps1

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ Param(
66
[parameter(Mandatory=$false)][string]$kubeconfigPath,
77
[parameter(Mandatory=$true)][string]$configFile,
88
[parameter(Mandatory=$false)][string]$imageTag,
9-
[parameter(Mandatory=$false)][string]$externalDns,
109
[parameter(Mandatory=$false)][bool]$deployCI=$false,
1110
[parameter(Mandatory=$false)][bool]$buildImages=$true,
12-
[parameter(Mandatory=$false)][bool]$buildBits=$false,
1311
[parameter(Mandatory=$false)][bool]$deployInfrastructure=$true,
1412
[parameter(Mandatory=$false)][string]$dockerOrg="eshop"
1513
)
@@ -30,6 +28,16 @@ function ExecKube($cmd) {
3028
$debugMode = $PSCmdlet.MyInvocation.BoundParameters["Debug"].IsPresent
3129
$useDockerHub = [string]::IsNullOrEmpty($registry)
3230

31+
$externalDns = & ExecKube -cmd 'get svc ingress-nginx -n ingress-nginx -o=jsonpath="{.status.loadBalancer.ingress[0].ip}"'
32+
Write-Host "Ingress ip detected: $externalDns" -ForegroundColor Yellow
33+
34+
if (-not [bool]($externalDns -as [ipaddress])) {
35+
Write-Host "Must install ingress first" -ForegroundColor Red
36+
Write-Host "Run deploy-ingress.ps1 and deploy-ingress-azure.ps1" -ForegroundColor Red
37+
exit
38+
}
39+
40+
3341
# Check required commands (only if not in CI environment)
3442
if(-not $deployCI) {
3543
$requiredCommands = ("docker", "docker-compose", "kubectl")
@@ -41,7 +49,6 @@ if(-not $deployCI) {
4149
}
4250
}
4351
else {
44-
$buildBits = false;
4552
$buildImages = false; # Never build images through CI, as they previously built
4653
}
4754

@@ -51,11 +58,7 @@ if ([string]::IsNullOrEmpty($imageTag)) {
5158
}
5259
Write-Host "Docker image Tag: $imageTag" -ForegroundColor Yellow
5360

54-
# building and publishing docker images if needed
55-
if($buildBits) {
56-
Write-Host "Building and publishing eShopOnContainers..." -ForegroundColor Yellow
57-
dotnet publish -c Release -o obj/Docker/publish ../eShopOnContainers-ServicesAndWebApps.sln
58-
}
61+
# building docker images if needed
5962
if ($buildImages) {
6063
Write-Host "Building Docker images tagged with '$imageTag'" -ForegroundColor Yellow
6164
$env:TAG=$imageTag
@@ -100,35 +103,18 @@ if (-not [string]::IsNullOrEmpty($dockerUser)) {
100103
Write-Host "Removing existing services & deployments.." -ForegroundColor Yellow
101104
ExecKube -cmd 'delete deployments --all'
102105
ExecKube -cmd 'delete services --all'
103-
ExecKube -cmd 'delete configmap config-files'
104106
ExecKube -cmd 'delete configmap urls'
105107
ExecKube -cmd 'delete configmap externalcfg'
106108

107109
# start sql, rabbitmq, frontend deployments
108-
ExecKube -cmd 'create configmap config-files --from-file=nginx-conf=nginx.conf'
109-
ExecKube -cmd 'label configmap config-files app=eshop'
110-
111110
if ($deployInfrastructure) {
112111
Write-Host 'Deploying infrastructure deployments (databases, redis, RabbitMQ...)' -ForegroundColor Yellow
113112
ExecKube -cmd 'create -f sql-data.yaml -f basket-data.yaml -f keystore-data.yaml -f rabbitmq.yaml -f nosql-data.yaml'
114113
}
115114

116-
Write-Host 'Deploying code deployments (Web APIs, Web apps, ...)' -ForegroundColor Yellow
117-
ExecKube -cmd 'create -f services.yaml -f frontend.yaml'
118-
119-
if ([string]::IsNullOrEmpty($externalDns)) {
120-
Write-Host "Waiting for frontend's external ip..." -ForegroundColor Yellow
121-
while ($true) {
122-
$frontendUrl = & ExecKube -cmd 'get svc frontend -o=jsonpath="{.status.loadBalancer.ingress[0].ip}"'
123-
if ([bool]($frontendUrl -as [ipaddress])) {
124-
break
125-
}
126-
Start-Sleep -s 15
127-
}
128-
$externalDns = $frontendUrl
129-
}
130115

131-
Write-Host "Using $externalDns as the external DNS/IP of the k8s cluster"
116+
Write-Host 'Deploying code deployments (Web APIs, Web apps, ...)' -ForegroundColor Yellow
117+
ExecKube -cmd 'create -f services.yaml'
132118

133119
ExecKube -cmd 'create configmap urls `
134120
--from-literal=BasketUrl=http://basket `

k8s/ingress.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Ingress
3+
metadata:
4+
labels:
5+
app: eshop
6+
component: frontend
7+
name: eshop-ingress
8+
annotations:
9+
ingress.kubernetes.io/ssl-redirect: "false"
10+
spec:
11+
rules:
12+
- http:
13+
paths:
14+
- path: /basket-api
15+
backend:
16+
serviceName: basket
17+
servicePort: 80
18+
- path: /catalog-api
19+
backend:
20+
serviceName: catalog
21+
servicePort: 80
22+
- path: /identity
23+
backend:
24+
serviceName: identity
25+
servicePort: 80
26+
- path: /ordering-api
27+
backend:
28+
serviceName: ordering
29+
servicePort: 80
30+
- path: /webmvc
31+
backend:
32+
serviceName: webmvc
33+
servicePort: 80
34+
- path: /webstatus
35+
backend:
36+
serviceName: webstatus
37+
servicePort: 80
38+
- path: /marketing-api
39+
backend:
40+
serviceName: marketing
41+
servicePort: 80
42+
- path: /payment-api
43+
backend:
44+
serviceName: payment
45+
servicePort: 80
46+
- path: /locations-api
47+
backend:
48+
serviceName: locations
49+
servicePort: 80
50+
- path: /
51+
backend:
52+
serviceName: webspa
53+
servicePort: 80
54+
55+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
kind: Service
2+
apiVersion: v1
3+
metadata:
4+
name: ingress-nginx
5+
namespace: ingress-nginx
6+
labels:
7+
app: ingress-nginx
8+
spec:
9+
externalTrafficPolicy: Local
10+
type: LoadBalancer
11+
selector:
12+
app: ingress-nginx
13+
ports:
14+
- name: http
15+
port: 80
16+
targetPort: http
17+
- name: https
18+
port: 443
19+
targetPort: https

k8s/nginx-ingress/configmap.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
kind: ConfigMap
2+
apiVersion: v1
3+
metadata:
4+
name: nginx-configuration
5+
namespace: ingress-nginx
6+
labels:
7+
app: ingress-nginx
8+
data:
9+
ssl-redirect: "false"
10+
proxy-buffer-size: "128k"
11+
proxy-buffers: "4 256k"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: default-http-backend
5+
labels:
6+
app: default-http-backend
7+
namespace: ingress-nginx
8+
spec:
9+
replicas: 1
10+
template:
11+
metadata:
12+
labels:
13+
app: default-http-backend
14+
spec:
15+
terminationGracePeriodSeconds: 60
16+
containers:
17+
- name: default-http-backend
18+
# Any image is permissable as long as:
19+
# 1. It serves a 404 page at /
20+
# 2. It serves 200 on a /healthz endpoint
21+
image: gcr.io/google_containers/defaultbackend:1.4
22+
livenessProbe:
23+
httpGet:
24+
path: /healthz
25+
port: 8080
26+
scheme: HTTP
27+
initialDelaySeconds: 30
28+
timeoutSeconds: 5
29+
ports:
30+
- containerPort: 8080
31+
resources:
32+
limits:
33+
cpu: 10m
34+
memory: 20Mi
35+
requests:
36+
cpu: 10m
37+
memory: 20Mi
38+
---
39+
40+
apiVersion: v1
41+
kind: Service
42+
metadata:
43+
name: default-http-backend
44+
namespace: ingress-nginx
45+
labels:
46+
app: default-http-backend
47+
spec:
48+
ports:
49+
- port: 80
50+
targetPort: 8080
51+
selector:
52+
app: default-http-backend

k8s/nginx-ingress/namespace.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: ingress-nginx
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: nginx-ingress-controller
5+
namespace: ingress-nginx
6+
spec:
7+
replicas: 1
8+
selector:
9+
matchLabels:
10+
app: ingress-nginx
11+
template:
12+
metadata:
13+
labels:
14+
app: ingress-nginx
15+
spec:
16+
containers:
17+
- name: nginx-ingress-controller
18+
image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.9.0
19+
args:
20+
- /nginx-ingress-controller
21+
- --default-backend-service=$(POD_NAMESPACE)/default-http-backend
22+
- --configmap=$(POD_NAMESPACE)/nginx-configuration
23+
- --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services
24+
- --udp-services-configmap=$(POD_NAMESPACE)/udp-services
25+
- --publish-service=$(POD_NAMESPACE)/ingress-nginx
26+
- --annotations-prefix=nginx.ingress.kubernetes.io
27+
env:
28+
- name: POD_NAME
29+
valueFrom:
30+
fieldRef:
31+
fieldPath: metadata.name
32+
- name: POD_NAMESPACE
33+
valueFrom:
34+
fieldRef:
35+
fieldPath: metadata.namespace
36+
ports:
37+
- name: http
38+
containerPort: 80
39+
- name: https
40+
containerPort: 443
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
'op': 'add',
4+
'path': '/spec/template/spec/containers/0/args/-',
5+
'value': '--publish-service=$(POD_NAMESPACE)/ingress-nginx'
6+
}
7+
]

0 commit comments

Comments
 (0)