Skip to content

Commit

Permalink
Initial Akri commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kate-goldenring committed Oct 14, 2020
0 parents commit 9414ef0
Show file tree
Hide file tree
Showing 184 changed files with 30,463 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

# Ignore everything
**

# ONVIF broker is built using a `docker build` command, so
# the source code needs to be available to the DotNet container
# build
!samples/brokers/onvif-video-broker

# The streaming app is built using a `docker build` command, so
# the source code needs to be available to the container
# build
!samples/apps/video-streaming-app

# The Rust binaries are not built with a `docker build`
# command (they are built using Cargo Cross, which I think
# uses a docker run). Because of this, the Rust src and
# Cargo.toml files can be ignored by docker.


# Cross-build binaries need to be available
# It is not clear to me why !target/*/*/controller
# does not work here, but it doesn't seem to. So
# for now, explicitly specifying each cross-build
# target and configuration path.
!target/x86_64-unknown-linux-gnu/debug/controller
!target/x86_64-unknown-linux-gnu/release/controller
!target/x86_64-unknown-linux-gnu/debug/agent
!target/x86_64-unknown-linux-gnu/release/agent
!target/x86_64-unknown-linux-gnu/debug/udev-video-broker
!target/x86_64-unknown-linux-gnu/release/udev-video-broker
!target/aarch64-unknown-linux-gnu/debug/controller
!target/aarch64-unknown-linux-gnu/release/controller
!target/aarch64-unknown-linux-gnu/debug/agent
!target/aarch64-unknown-linux-gnu/release/agent
!target/aarch64-unknown-linux-gnu/debug/udev-video-broker
!target/aarch64-unknown-linux-gnu/release/udev-video-broker
!target/arm-unknown-linux-gnueabihf/debug/controller
!target/arm-unknown-linux-gnueabihf/release/controller
!target/arm-unknown-linux-gnueabihf/debug/agent
!target/arm-unknown-linux-gnueabihf/release/agent
!target/arm-unknown-linux-gnueabihf/debug/udev-video-broker
!target/arm-unknown-linux-gnueabihf/release/udev-video-broker

# Cross toml file needs to be available for making the cross build containers
!Cross.toml

# Container image license to be copied into every container
!build/container-images-legal-notice.md
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://help.github.com/en/articles/about-code-owners#codeowners-syntax

* @bfjelds @kate-goldenring @jiria @britel
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**Output of `kubectl get pods,akrii,akric -o wide`**

**Kubernetes Version: [e.g. Native Kubernetes 1.19, MicroK8s 1.19, Minikube 1.19, K3s]**

**To Reproduce**
Steps to reproduce the behavior:
1. Create cluster using '...'
2. Install Akri with the Helm command '...'
3. '...'

**Expected behavior**
A clear and concise description of what you expected to happen.

**Logs (please share snips of applicable logs)**
- To get the logs of any pod, run `kubectl get logs <pod name>`
- To get the logs of a pod that has already terminated, `kubectl get logs <pod name> --previous`
- If you believe that the problem is with the Kubelet, run `journalctl -u kubelet` or `journalctl -u snap.microk8s.daemon-kubelet` if you are using a MicroK8s cluster.

**Additional context**
Add any other context about the problem here.
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: feature
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Is your feature request related to a way you would like Akri extended? Please describe.**
A clear and concise description of what cool feature Akri lacks. Ex. I'd love Akri to support discovery of Bluetooth devices.

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
27 changes: 27 additions & 0 deletions .github/actions/build-component-multi-arch/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'build-component-multi-arch'
description: 'Build Akri Component Container'
inputs:
container_registry_base_url:
description: Azure Container Registry
required: true
container_registry_username:
description: Azure Container Registry name
required: true
container_registry_password:
description: Azure Container Registry password
required: true
container_name:
description: Component container name
required: true
container_prefix:
description: Container prefix (i.e. 'myacr.acr.io/foo' for myacr.acr.io/foo/container:label)
required: true
makefile_component_name:
description: Component prefix used by Makefile
required: true
github_event_name:
description: Specify the github event name (push, pull_request, release, etc)
required: true
runs:
using: 'node12'
main: 'main.js'
62 changes: 62 additions & 0 deletions .github/actions/build-component-multi-arch/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const exec = require('@actions/exec');
const core = require('@actions/core');
const child_process = require('child_process');
const fs = require("fs");

async function shell_cmd(cmd) {
return await new Promise((resolve, reject) => {
child_process.exec(cmd, function(error, stdout, stderr) {
if (error) {
console.log(`... error=${error}`)
reject(error)
}

if (stderr) {
console.log(`... stderr=${stderr.trim()}`)
}

console.log(`... stdout=${stdout.trim()}`)
resolve(stdout.trim());
});
});
}

(async () => {
try {
console.log(`Start main.js`)

var dev_suffix = (core.getInput('github_event_name') == "release") ? "" : "-dev";
const versioned_label = `v${fs.readFileSync('./version.txt').toString().trim()}${dev_suffix}`;
const latest_label = `latest${dev_suffix}`;
console.log(`Use labels: versioned=${versioned_label} latest=${latest_label}`);

console.log(`Login into Container Registry user=${core.getInput('container_registry_username')} repo=${core.getInput('container_registry_base_url')}`);
await shell_cmd(`echo "${core.getInput('container_registry_password')}" | docker login -u ${core.getInput('container_registry_username')} --password-stdin ${core.getInput('container_registry_base_url')}`);

process.env.DOCKER_CLI_EXPERIMENTAL = `enabled`
process.env.PREFIX = `${core.getInput('container_prefix')}`
process.env.LABEL_PREFIX = `${versioned_label}`

console.log(`echo Create multi-arch versioned manifest`)
await exec.exec(`make ${core.getInput('makefile_component_name')}-docker-multi-arch-create`)

console.log(`echo Inspect multi-arch versioned manifest`)
await exec.exec(`docker manifest inspect ${core.getInput('container_prefix')}/${core.getInput('container_name')}:${versioned_label}`)

console.log(`echo Push multi-arch versioned manifest`)
await exec.exec(`make ${core.getInput('makefile_component_name')}-docker-multi-arch-push`)

process.env.LABEL_PREFIX = `${latest_label}`

console.log(`echo Create multi-arch latest manifest`)
await exec.exec(`make ${core.getInput('makefile_component_name')}-docker-multi-arch-create`)

console.log(`echo Inspect multi-arch latest manifest`)
await exec.exec(`docker manifest inspect ${core.getInput('container_prefix')}/${core.getInput('container_name')}:${latest_label}`)

console.log(`echo Push multi-arch latest manifest`)
await exec.exec(`make ${core.getInput('makefile_component_name')}-docker-multi-arch-push`)
} catch (error) {
core.setFailed(error);
}
})();
10 changes: 10 additions & 0 deletions .github/actions/build-component-multi-arch/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"private": true,
"name": "build-component-multi-arch",
"dependencies": {
"@actions/core": "^1.2.2",
"@actions/exec": "1.0.2",
"child_process": "^1.0.2",
"fs": "^8.1.0"
}
}
42 changes: 42 additions & 0 deletions .github/actions/build-component-per-arch/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: 'build-component-per-arch'
description: 'Build Akri Component Container'
inputs:
container_registry_base_url:
description: Azure Container Registry
required: true
container_registry_username:
description: Azure Container Registry name
required: true
container_registry_password:
description: Azure Container Registry password
required: true
container_name:
description: Component container name
required: true
container_prefix:
description: Container prefix (i.e. 'myacr.acr.io/foo' for myacr.acr.io/foo/container:label)
required: true
makefile_component_name:
description: Component prefix used by Makefile
required: true
platform:
description: Platform to build (amd64|arm64|arm32)
required: true
build_rust:
description: Specify whether rust is being built
required: true
github_event_name:
description: Specify the github event name (push, pull_request, release, etc)
required: true
github_ref:
description: Specify the github ref
required: true
github_event_action:
description: Specify the github event action (i.e. closed)
required: true
github_merged:
description: Specify whether a PR has been merged
required: true
runs:
using: 'node12'
main: 'main.js'
106 changes: 106 additions & 0 deletions .github/actions/build-component-per-arch/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
const exec = require('@actions/exec');
const core = require('@actions/core');
const child_process = require('child_process');
const fs = require("fs");

async function shell_cmd(cmd) {
return await new Promise((resolve, reject) => {
child_process.exec(cmd, function(error, stdout, stderr) {
if (error) {
console.log(`... error=${error}`)
reject(error)
}

if (stderr) {
console.log(`... stderr=${stderr.trim()}`)
}

console.log(`... stdout=${stdout.trim()}`)
resolve(stdout.trim());
});
});
}

(async () => {
try {
console.log(`Start main.js`)

console.log(`Use multiarch/qemu-user-static to configure cross-plat`);
await shell_cmd('docker run --rm --privileged multiarch/qemu-user-static --reset -p yes');

var dev_suffix = (core.getInput('github_event_name') == "release") ? "" : "-dev";
const versioned_label = `v${fs.readFileSync('./version.txt').toString().trim()}${dev_suffix}`;
const latest_label = `latest${dev_suffix}`;
console.log(`Use labels: versioned=${versioned_label} latest=${latest_label}`);

var push_containers = 0;
if (core.getInput('github_event_name') == 'release') push_containers = 1;
else if (core.getInput('github_event_name') == 'push' &&
core.getInput('github_ref') == 'refs/heads/main') push_containers = 1;
else if (core.getInput('github_event_name') == 'pull_request' &&
core.getInput('github_event_action') == 'closed' &&
core.getInput('github_ref') == 'refs/heads/main' &&
core.getInput('github_merged') == 'true') push_containers = 1;
else console.log(`Not pushing containers ... event: ${core.getInput('github_event_name')}, ref: ${core.getInput('github_ref')}, action: ${core.getInput('github_event_action')}, merged: ${core.getInput('github_merged')}`);
console.log(`Push containers: ${push_containers}`);

var makefile_target_suffix = "";
switch (core.getInput('platform')) {
case "amd64": makefile_target_suffix = "amd64"; break;
case "arm32v7": makefile_target_suffix = "arm32"; break;
case "arm64v8": makefile_target_suffix = "arm64"; break;
default:
core.setFailed(`Failed with unknown platform: ${core.getInput('platform')}`)
return
}
console.log(`Makefile build target suffix: ${makefile_target_suffix}`)

console.log(`Login into Container Registry user=${core.getInput('container_registry_username')} repo=${core.getInput('container_registry_base_url')}`);
await shell_cmd(`echo "${core.getInput('container_registry_password')}" | docker login -u ${core.getInput('container_registry_username')} --password-stdin ${core.getInput('container_registry_base_url')}`);

if (core.getInput('build_rust') == '1') {
console.log(`Install Rust`)
child_process.execSync(`curl https://sh.rustup.rs | sh -s -- -y --default-toolchain=1.41.0`);
const bindir = `${process.env.HOME}/.cargo/bin`;
process.env.PATH = `${process.env.PATH}:${bindir}`;

console.log(`Check cargo version`)
await shell_cmd('cargo --version')
console.log(`Install Cross`)
await shell_cmd('make install-cross')
await shell_cmd('cross --version')
console.log(`Cross compile: akri-cross-build-${makefile_target_suffix}`)
await exec.exec(`make akri-cross-build-${makefile_target_suffix}`)
} else {
console.log(`Not building Rust: ${core.getInput('build_rust')}`)
}

process.env.PREFIX = `${core.getInput('container_prefix')}`

console.log(`Build the versioned container: make ${core.getInput('makefile_component_name')}-build-${makefile_target_suffix}`)
process.env.LABEL_PREFIX = `${versioned_label}`
await exec.exec(`make ${core.getInput('makefile_component_name')}-build-${makefile_target_suffix}`)

console.log(`Build the latest container: make ${core.getInput('makefile_component_name')}-build-${makefile_target_suffix}`)
process.env.LABEL_PREFIX = `${latest_label}`
await exec.exec(`make ${core.getInput('makefile_component_name')}-build-${makefile_target_suffix}`)

const image_name = `${core.getInput('container_prefix')}/${core.getInput('container_name')}:${versioned_label}-${core.getInput('platform')}`
console.log(`Check that container contains container-images-legal-notice.md: ${image_name}`)
await shell_cmd(`docker run ${image_name} find container-images-legal-notice.md | wc -l | grep -v 0`)

if (push_containers == "1") {
console.log(`Push the versioned container: make ${core.getInput('makefile_component_name')}-docker-per-arch-${makefile_target_suffix}`)
process.env.LABEL_PREFIX = `${versioned_label}`
await exec.exec(`make ${core.getInput('makefile_component_name')}-docker-per-arch-${makefile_target_suffix}`)

console.log(`Push the latest container: make ${core.getInput('makefile_component_name')}-docker-per-arch-${makefile_target_suffix}`)
process.env.LABEL_PREFIX = `${latest_label}`
await exec.exec(`make ${core.getInput('makefile_component_name')}-docker-per-arch-${makefile_target_suffix}`)
} else {
console.log(`Not pushing containers: ${push_containers}`)
}
} catch (error) {
core.setFailed(error);
}
})();
10 changes: 10 additions & 0 deletions .github/actions/build-component-per-arch/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"private": true,
"name": "build-component-per-arch",
"dependencies": {
"@actions/core": "^1.2.2",
"@actions/exec": "1.0.2",
"child_process": "^1.0.2",
"fs": "^8.1.0"
}
}
Loading

0 comments on commit 9414ef0

Please sign in to comment.