Skip to content
This repository was archived by the owner on Feb 22, 2025. It is now read-only.

Commit 7baa01c

Browse files
authored
Merge pull request #21 from janegilring/hello-arc-windows-support
Added src for hello-arc-windows
2 parents dd25ca3 + eac081d commit 7baa01c

File tree

9 files changed

+243
-0
lines changed

9 files changed

+243
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM azurearcjumpstart.azurecr.io/node-windows-servercore:ltsc2019
2+
3+
ARG IMAGE_CREATE_DATE
4+
ARG IMAGE_VERSION
5+
ARG IMAGE_SOURCE_REVISION
6+
7+
# Metadata as defined in OCI image spec annotations - https://github.com/opencontainers/image-spec/blob/master/annotations.md
8+
LABEL org.opencontainers.image.title="Hello Arc!" \
9+
org.opencontainers.image.description="Provides a demo app to deploy to an Azure Arc-enabled Kubernetes cluster. It displays a message, the name of the pod and details of the node it is deployed to." \
10+
org.opencontainers.image.created=$IMAGE_CREATE_DATE \
11+
org.opencontainers.image.version=$IMAGE_VERSION \
12+
org.opencontainers.image.authors="Jan Egil Ring" \
13+
org.opencontainers.image.url="azurearcjumpstart.azurecr.io/hello-arc:windows" \
14+
org.opencontainers.image.documentation="https://github.com/microsoft/azure-arc-jumpstart-apps/tree/main/hello-arc-windows" \
15+
org.opencontainers.image.vendor="Microsoft" \
16+
org.opencontainers.image.licenses="MIT" \
17+
org.opencontainers.image.source="https://github.com/microsoft/azure-arc-jumpstart-apps.git" \
18+
org.opencontainers.image.revision=$IMAGE_SOURCE_REVISION
19+
20+
# Create app directory
21+
RUN mkdir -p c:\app
22+
WORKDIR c:\\app
23+
24+
# Install app dependencies
25+
COPY package.json c:\\app
26+
RUN npm install
27+
28+
# Bundle app source
29+
COPY . c:\\app
30+
31+
#USER node
32+
CMD [ "C:\\nodejs\\npm.cmd", "start" ]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "hello-kubernetes",
3+
"version": "1.8.0",
4+
"description": "Hello Kubernetes!",
5+
"author": "Paul Bouwer",
6+
"license": "MIT",
7+
"main": "server.js",
8+
"scripts": {
9+
"start": "node server.js"
10+
},
11+
"dependencies": {
12+
"bytes": "^3.1.0",
13+
"express": "^4.17.1",
14+
"express-handlebars": "^3.1.0",
15+
"handlebars": "^4.7.6",
16+
"minimist": ">=1.2.5",
17+
"morgan": "^1.9.1"
18+
}
19+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
var express = require('express');
2+
var exphbs = require('express-handlebars');
3+
var app = express();
4+
var os = require("os");
5+
var morgan = require('morgan');
6+
7+
app.engine('handlebars', exphbs({defaultLayout: 'main'}));
8+
app.set('view engine', 'handlebars');
9+
app.use(express.static('static'));
10+
app.use(morgan('combined'));
11+
12+
// Configuration
13+
var port = process.env.PORT || 8080;
14+
var message = process.env.MESSAGE || "Hello Azure Arc GitOps Demo!";
15+
16+
app.get('/', function (req, res) {
17+
res.render('home', {
18+
message: message,
19+
platform: os.type(),
20+
release: os.release(),
21+
hostName: os.hostname()
22+
});
23+
});
24+
25+
// Set up listener
26+
app.listen(port, function () {
27+
console.log("Listening on: http://%s:%s", os.hostname(), port);
28+
});
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
body {
2+
margin:0;
3+
padding:0;
4+
background-color:white;
5+
}
6+
7+
div.main {
8+
text-align: center;
9+
}
10+
11+
div.main img {
12+
margin: 40px 0;
13+
}
14+
15+
div.content {
16+
color:#f2f2f2;
17+
}
18+
.content #message {
19+
margin: 10px 0 50px 0;
20+
padding: 30px 0;
21+
font-family: 'Ubuntu', sans-serif;
22+
font-weight: 300;
23+
font-size: 44pt;
24+
background-color: #1a6ad3;
25+
/* border-top: 2px solid #909090;
26+
border-bottom: 2px solid #909090; */
27+
}
28+
29+
.content #info {
30+
margin: 0 auto;
31+
font-family: 'Ubuntu', sans-serif;
32+
font-weight: 300;
33+
font-size: 16pt;
34+
color: black;
35+
}
36+
37+
.content #info table {
38+
margin: 10px auto;
39+
}
40+
41+
.content #info table th {
42+
text-align: right;
43+
padding-right: 20px;
44+
}
45+
46+
.content #info table td {
47+
text-align: left;
48+
}
49+
32.1 KB
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div id="message">
2+
{{ message }}
3+
</div>
4+
<div id="info">
5+
<table>
6+
<tr>
7+
<th>pod:</th>
8+
<td>{{ hostName }}</td>
9+
</tr>
10+
<tr>
11+
<th>node:</th>
12+
<td>{{ platform }} ({{ release }})</td>
13+
</tr>
14+
</table>
15+
16+
</div>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Hello Kubernetes!</title>
5+
<link rel="stylesheet" type="text/css" href="/css/main.css">
6+
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu:300" >
7+
</head>
8+
<body>
9+
10+
<div class="main">
11+
<img src="/images/logo.png"/>
12+
<div class="content">
13+
{{{body}}}
14+
</div>
15+
</div>
16+
17+
</body>
18+
</html>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
FROM mcr.microsoft.com/windows/servercore:ltsc2019
2+
3+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
4+
5+
# PATH isn't actually set in the Docker image, so we have to set it from within the container
6+
RUN $newPath = ('C:\nodejs;{0}\Yarn\bin;{1}' -f $env:LOCALAPPDATA, $env:PATH); \
7+
Write-Host ('Updating PATH: {0}' -f $newPath); \
8+
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine)
9+
# doing this first to share cache across versions more aggressively
10+
11+
ENV NODE_VERSION 18.14.0
12+
ENV NODE_SHA256 2e8f00da72f6bd993e3b980ff844b948baf936e1e67e3694a7a3e5f6f7c9beb4
13+
14+
RUN $url = ('https://nodejs.org/dist/v{0}/node-v{0}-win-x64.zip' -f $env:NODE_VERSION); \
15+
Write-Host ('Downloading {0} ...' -f $url); \
16+
Invoke-WebRequest -Uri $url -OutFile 'node.zip'; \
17+
\
18+
Write-Host ('Verifying sha256 ({0}) ...' -f $env:NODE_SHA256); \
19+
if ((Get-FileHash node.zip -Algorithm sha256).Hash -ne $env:NODE_SHA256) { throw 'SHA256 mismatch' }; \
20+
\
21+
Write-Host 'Expanding ...'; \
22+
Expand-Archive node.zip -DestinationPath C:\; \
23+
\
24+
Write-Host 'Renaming ...'; \
25+
Rename-Item -Path ('C:\node-v{0}-win-x64' -f $env:NODE_VERSION) -NewName 'C:\nodejs'; \
26+
\
27+
Write-Host 'Removing ...'; \
28+
Remove-Item node.zip -Force; \
29+
\
30+
Write-Host 'Verifying ("node --version") ...'; \
31+
node --version; \
32+
Write-Host 'Verifying ("npm --version") ...'; \
33+
npm --version; \
34+
\
35+
Write-Host 'Complete.'
36+
37+
ENV YARN_VERSION 1.22.17
38+
39+
# "It is recommended to install Yarn through the npm package manager" (https://classic.yarnpkg.com/en/docs/install)
40+
RUN Write-Host 'Installing "yarn" ...'; \
41+
npm install --global ('yarn@{0}' -f $env:YARN_VERSION); \
42+
\
43+
Write-Host 'Verifying ("yarn --version") ...'; \
44+
yarn --version; \
45+
\
46+
Write-Host 'Complete.'
47+
48+
CMD [ "node" ]

hello-arc-windows/src/test.ps1

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
cd /workspaces
2+
git clone https://github.com/microsoft/azure-arc-jumpstart-apps.git
3+
4+
cd /workspaces/azure-arc-jumpstart-apps/hello-arc-windows/src
5+
6+
# Build Windows Server container image with Node installed, needed as Node does not have an official Windows image per 2023-02-08: https://github.com/nodejs/docker-node/pull/362
7+
docker build ./node -t azurearcjumpstart.azurecr.io/node-windows-servercore:ltsc2019
8+
9+
docker push azurearcjumpstart.azurecr.io/node-windows-servercore:ltsc2019
10+
11+
# Build node application
12+
docker build ./app -t azurearcjumpstart.azurecr.io/hello-arc:windows
13+
14+
docker push azurearcjumpstart.azurecr.io/hello-arc:windows
15+
16+
# Test locally
17+
docker run -d -p 8080:8080 azurearcjumpstart.azurecr.io/hello-arc:windows
18+
19+
# AKS
20+
az login
21+
az aks get-credentials --resource-group aks-demo-rg --name aks-demo
22+
23+
# Test Linux image on AKS Linux node
24+
kubectl run hello-arc-linux --image liorkamrat/hello-arc --overrides='{"apiVersion": "v1", "spec": {"nodeSelector": { "kubernetes.io/os": "linux" }}}'
25+
26+
# Verify app is working
27+
kubectl port-forward hello-arc-linux 8080:8080
28+
29+
# Test Windows image on AKS Windows node
30+
kubectl run hello-arc-windows --image azurearcjumpstart.azurecr.io/hello-arc:windows --overrides='{"apiVersion": "v1", "spec": {"nodeSelector": { "kubernetes.io/os": "windows" }}}'
31+
32+
# Verify app is working
33+
kubectl port-forward hello-arc-windows 8080:8080

0 commit comments

Comments
 (0)