Skip to content

Commit

Permalink
Merge pull request #1 from canonical/kf-4450-feat-metacontroller-rock
Browse files Browse the repository at this point in the history
# Description

`metacontroller` container image should be converted to ROCK.
This PR contains initial ROCK implementation based on best practices.

# Summary of changes:
- Initial ROCK based on the same version of source code as upstream container.

# Scan results:

ROCK image `metacontroller:2.0.4_22.04_1`
CRITICAL: 0 HIGH: 14 MED: 6 LOW: 0

As compared to upstream image `metacontroller:2.0.4`
CRITICAL: 3 HIGH: 41 MED: 11 LOW: 0

# Testing

Manual testing was performed. See the log below.

<details><summary>Manual test log</summary>

```
$ docker run charmedkubeflow/metacontroller:2.0.4_22.04_1 exec pebble start metacontroller
2023-09-26T15:48:59.689Z [pebble] Started daemon.
2023-09-26T15:48:59.710Z [pebble] POST /v1/exec 20.143166ms 202
2023-09-26T15:48:59.727Z [pebble] GET /v1/tasks/1/websocket/control 16.942361ms 200
2023-09-26T15:48:59.727Z [pebble] GET /v1/tasks/1/websocket/stdio 62.045µs 200
2023-09-26T15:48:59.727Z [pebble] GET /v1/tasks/1/websocket/stderr 85.937µs 200
2023-09-26T15:48:59.768Z [pebble] POST /v1/services 27.166079ms 202
2023-09-26T15:48:59.768Z [pebble] Service "metacontroller" starting: metacontroller
2023-09-26T15:48:59.779Z [metacontroller] {"level":"info","ts":1695743339.779103,"msg":"Discovery cache flush interval","discovery_interval":30}
2023-09-26T15:48:59.779Z [metacontroller] {"level":"info","ts":1695743339.7791352,"msg":"API server object cache flush interval","cache_flush_interval":1800}
2023-09-26T15:48:59.779Z [metacontroller] {"level":"info","ts":1695743339.7791398,"msg":"Metrics http server address","port":":9999"}
2023-09-26T15:48:59.779Z [metacontroller] {"level":"info","ts":1695743339.7791443,"msg":"Metacontroller build information","version":"dev"}
2023-09-26T15:48:59.779Z [metacontroller] {"level":"error","ts":1695743339.7792091,"msg":"Terminating","error":"invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable","errorCauses":[{"error":"no configuration has been provided, try setting KUBERNETES_MASTER environment variable"}],"stacktrace":"runtime.main\n\t/snap/go/9362/src/runtime/proc.go:225"}
error: cannot perform the following tasks:
- Start service "metacontroller" (cannot start service: exited quickly with code 1)
2023-09-26T15:48:59.905Z [pebble] GET /v1/changes/1/wait 176.788211ms 200
```

</details>
  • Loading branch information
i-chvets authored Oct 3, 2023
2 parents da78b20 + 0f8f4c9 commit ad61a07
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Based on https://github.com/metacontroller/metacontroller/blob/v2.0.4/Dockerfile
name: metacontroller
summary: Metacontroller in a ROCK.
description: "Metacontroller is an add-on for Kubernetes that makes it easy to write and deploy custom controllers in the form of simple scripts."
version: "2.0.4_22.04_1"
license: Apache-2.0
build-base: ubuntu:22.04
base: bare
run-user: _daemon_
services:
metacontroller:
command: metacontroller
working-dir: /usr/bin
override: replace
startup: enabled
platforms:
amd64:

parts:
metacontroller:
plugin: go
source: https://github.com/metacontroller/metacontroller
source-type: git
source-tag: "v2.0.4"
build-snaps:
- go/1.16/stable
build-environment:
- CGO_ENABLED: 0
stage-packages:
- ca-certificates
override-build: |
make install
mkdir -p ${CRAFT_PART_INSTALL}/usr/bin
install -D ${CRAFT_PART_INSTALL}/bin/metacontroller ${CRAFT_PART_INSTALL}/usr/bin
security-team-requirement:
plugin: nil
override-build: |
# security requirement
# there are no packages installed in `bare` base which is used in this rock
mkdir -p ${CRAFT_PART_INSTALL}/usr/share/rocks
(echo "# os-release" && cat /etc/os-release && echo "# dpkg-query") \
> ${CRAFT_PART_INSTALL}/usr/share/rocks/dpkg.query

0 comments on commit ad61a07

Please sign in to comment.