Skip to content

Commit 0bff54f

Browse files
authored
Enable BCS pod launcher POC with docker/k8s mode (#26)
The BCS Pod Launcher is a tool designed to start a Media Proxy Agent instance on one machine and MCM Media Proxy instances on each machine. It enables the initiation of the BCS ffmpeg pipeline with a bound NMOS client node application. The tool can operate in two modes: Kubernetes Mode: For multi-node cluster deployment. Docker Mode: For single-node deployment using Docker containers. Added core for controllers - for docker and kubernetes mode Added manifests for kubernetes Defined input file for k8s mode Add instructions to run in README Added prototyped core for BCS pod (and containers) launcher. Extending to containers support: Decouple functionality of docker and k8s mode Reorganize file with configuration Add silent MCM installation Note that resources have not been completely configured. This poc only covers flow and algorithms in bcs launcher
1 parent 3fa74e7 commit 0bff54f

28 files changed

+3042
-0
lines changed

launcher/.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# SPDX-FileCopyrightText: Copyright (c) 2024 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
7+
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
8+
# Ignore build and test binaries.
9+
bin/

launcher/.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# SPDX-FileCopyrightText: Copyright (c) 2024 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
7+
# Binaries for programs and plugins
8+
*.exe
9+
*.exe~
10+
*.dll
11+
*.so
12+
*.dylib
13+
bin/*
14+
Dockerfile.cross
15+
16+
# Test binary, built with `go test -c`
17+
*.test
18+
19+
# Output of the go coverage tool, specifically when used with LiteIDE
20+
*.out
21+
22+
# Go workspace file
23+
go.work
24+
25+
# Kubernetes Generated files - skip generated files, except for vendored files
26+
!vendor/**/zz_generated.*
27+
28+
# editor and IDE paraphernalia
29+
.idea
30+
.vscode
31+
*.swp
32+
*.swo
33+
*~

launcher/Dockerfile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright 2024.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS,
8+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
# See the License for the specific language governing permissions and
10+
# limitations under the License.
11+
12+
# SPDX-FileCopyrightText: Copyright (c) 2024 Intel Corporation
13+
#
14+
# SPDX-License-Identifier: BSD-3-Clause
15+
16+
# Build the manager binary
17+
FROM golang:1.23 AS builder
18+
ARG TARGETOS
19+
ARG TARGETARCH
20+
21+
WORKDIR /workspace
22+
# Copy the Go Modules manifests
23+
COPY go.mod go.mod
24+
COPY go.sum go.sum
25+
RUN go mod download
26+
27+
# Copy the go source
28+
COPY cmd/main.go cmd/main.go
29+
COPY api/ api/
30+
COPY internal/ internal/
31+
COPY resources_library/ resources_library/
32+
33+
# Build
34+
# the GOARCH has not a default value to allow the binary be built according to the host where the command
35+
# was called.
36+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
37+
38+
# # Use distroless as minimal base image to package the manager binary
39+
# # Refer to https://github.com/GoogleContainerTools/distroless for more details
40+
FROM gcr.io/distroless/static:nonroot
41+
WORKDIR /
42+
COPY --from=builder /workspace/manager .
43+
USER 65532:65532
44+
45+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD [ "curl", "-f", "http://localhost:8081/healthz" ] || exit 1
46+
47+
ENTRYPOINT ["/manager"]

launcher/PROJECT

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2024.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS,
8+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
# See the License for the specific language governing permissions and
10+
# limitations under the License.
11+
12+
13+
# SPDX-FileCopyrightText: Copyright (c) 2024 Intel Corporation
14+
#
15+
# SPDX-License-Identifier: BSD-3-Clause
16+
17+
domain: bcs.intel
18+
layout:
19+
- go.kubebuilder.io/v4
20+
plugins:
21+
manifests.sdk.operatorframework.io/v2: {}
22+
scorecard.sdk.operatorframework.io/v2: {}
23+
projectName: bcs-launcher
24+
repo: bcs.pod.launcher.intel
25+
resources:
26+
- api:
27+
crdVersion: v1
28+
namespaced: true
29+
controller: true
30+
domain: bcs.intel
31+
group: bcs
32+
kind: BcsConfig
33+
path: bcs.pod.launcher.intel/api/v1
34+
version: v1
35+
version: "3"

launcher/README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# BCS pod launcher
2+
3+
BCS pod launcher starts once Media Proxy Agent instance (on one machine) and MCM Media Proxy instances on each machine. It enables to starts BCS ffmpeg pipeline with bound NMOS client node application.
4+
5+
## Description
6+
7+
The tool can operate in two modes:
8+
9+
- Kubernetes Mode: For multi-node cluster deployment.
10+
- Docker Mode: For single-node using Docker containers.
11+
12+
**Flow (Common to Both Modes)**
13+
14+
1. Run MediaProxy Agent
15+
2. Run MCM Media Proxy
16+
3. Run BcsFfmpeg pipeline with NMOS
17+
18+
In case of docker, MediaProxy/MCM things should only start/run once and on every run of launcher, one should start the app according to input file. It does not store the state of apps, just check appropriate conditions.
19+
20+
In case of kuberenetes, MediaProxy/MCM things should only be run once and BCS pod launcher works as operator in the understanding of Kuberenetes operators within pod. That is way, input file in this way is CustomReaource called BcsConfig.
21+
22+
## Getting Started
23+
24+
### Prerequisites
25+
26+
- go version v1.22.0+
27+
- docker version 17.03+.
28+
- kubectl version v1.27+
29+
- Access to a Kubernetes v1.11.3+ cluster.
30+
31+
### To Run containers on single node
32+
33+
```bash
34+
# currently only in dev phase
35+
cd <repo>/launcher/cmd/
36+
# Adjust to your needs: ./configuration_files/bcslauncher-static-config.yaml
37+
go run main.go
38+
39+
```
40+
41+
### To Deploy on the cluster
42+
43+
**Build image:**
44+
Modify `./launcher/configuration_files/bcslauncher-static-config.yaml`. `k8s: false` defines docker (containers on single host) mode.
45+
`docker build -t controller:bcs_pod_launcher .`
46+
47+
**BCS pod launcher installer in k8s cluster:**
48+
49+
Users can just run kubectl apply -f <file> to install the project:
50+
51+
```bash
52+
cd <repo>/launcher/
53+
kubectl apply -f ./configuration_files/bcslauncher-k8s-config.yaml
54+
kubectl apply -f ./configuration_files/bcsconfig-crd.yaml
55+
kubectl apply -f ./configuration_files/bcs-launcher.yaml
56+
# Adjust to your needs: ./configuration_files/bcsconfig-example.yaml
57+
kubectl apply -f ./configuration_files/bcsconfig-example.yaml
58+
59+
```
60+
61+
**BCS pod launcher roles of files in k8s cluster:**
62+
63+
- `configuration_files/bcslauncher-k8s-config.yaml` -> configmap for setting up the mode of launcher. `k8s: true` defines kuberenets mode. Currently, you should not modify this in that file.
64+
- `configuration_files/bcs-launcher.yaml` -> install set of kuberenetes resources that are needed to run bcs pod luancher, no additional configuration required
65+
- `configuration_files/bcsconfig-crd.yaml` -> Custom Resource Definition for `BcsConfig`
66+
- `configuration_files/bcsconfig-example.yaml` -> example `BcsConfig` file that it is an input to provide information about **bcs ffmpeg piepeline and NMOS client**, you can adjust file to your needs,
67+
- `configuration_files/bcslauncher-static-config.yaml` -> static config for docker mode. `k8s: false` defines docker mode. Currently, you should not modify this in that file.
68+
69+
**BCS pod launcher deletion of implementationn of BCS pod launcher in k8s cluster:**
70+
71+
```bash
72+
cd <repo>/launcher/
73+
kubectl delete -f ./configuration_files/bcslauncher-k8s-config.yaml
74+
kubectl delete -f ./configuration_files/bcsconfig-crd.yaml
75+
kubectl delete -f ./configuration_files/bcs-launcher.yaml
76+
kubectl delete -f ./configuration_files/bcsconfig-example.yaml
77+
```
78+
79+
## License
80+
81+
SPDX-FileCopyrightText: Copyright (c) 2024 Intel Corporation
82+
83+
SPDX-License-Identifier: BSD-3-Clause
84+
85+
===============================================================
86+
87+
Copyright 2024.
88+
89+
Licensed under the Apache License, Version 2.0 (the "License");
90+
you may not use this file except in compliance with the License.
91+
You may obtain a copy of the License at
92+
93+
http://www.apache.org/licenses/LICENSE-2.0
94+
95+
Unless required by applicable law or agreed to in writing, software
96+
distributed under the License is distributed on an "AS IS" BASIS,
97+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
98+
See the License for the specific language governing permissions and
99+
limitations under the License.

launcher/api/v1/bcsconfig_types.go

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
Copyright 2024.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
/*
18+
* SPDX-FileCopyrightText: Copyright (c) 2024 Intel Corporation
19+
*
20+
* SPDX-License-Identifier: BSD-3-Clause
21+
*/
22+
23+
package v1
24+
25+
import (
26+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27+
)
28+
29+
// BcsConfigSpec defines the desired state of BcsConfig
30+
type BcsConfigSpec struct {
31+
AppParams AppParams `json:"appParams"`
32+
Connections Connections `json:"connections"`
33+
}
34+
35+
type AppParams struct {
36+
UniqueName string `json:"uniqueName"`
37+
Codec string `json:"codec"`
38+
PixelFormat string `json:"pixelFormat"`
39+
Height int `json:"height"`
40+
Width int `json:"width"`
41+
}
42+
43+
type Connections struct {
44+
DataConnection DataConnection `json:"dataConnection"`
45+
ControlConnection ControlConnection `json:"controlConnection"`
46+
}
47+
48+
type DataConnection struct {
49+
ConnType string `json:"connType"`
50+
MediaProxyIpAddress string `json:"mediaProxyIpAddress"`
51+
Port int `json:"port"`
52+
}
53+
54+
type ControlConnection struct {
55+
IpAddress string `json:"ipAddress"`
56+
Port int `json:"port"`
57+
}
58+
59+
// BcsConfigStatus defines the observed state of BcsConfig
60+
type BcsConfigStatus struct {
61+
}
62+
63+
//+kubebuilder:object:root=true
64+
//+kubebuilder:subresource:status
65+
66+
// BcsConfig is the Schema for the bcsconfigs API
67+
type BcsConfig struct {
68+
metav1.TypeMeta `json:",inline"`
69+
metav1.ObjectMeta `json:"metadata,omitempty"`
70+
71+
Spec BcsConfigSpec `json:"spec,omitempty"`
72+
Status BcsConfigStatus `json:"status,omitempty"`
73+
}
74+
75+
//+kubebuilder:object:root=true
76+
77+
// BcsConfigList contains a list of BcsConfig
78+
type BcsConfigList struct {
79+
metav1.TypeMeta `json:",inline"`
80+
metav1.ListMeta `json:"metadata,omitempty"`
81+
Items []BcsConfig `json:"items"`
82+
}
83+
84+
func init() {
85+
SchemeBuilder.Register(&BcsConfig{}, &BcsConfigList{})
86+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
Copyright 2024.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
/*
18+
* SPDX-FileCopyrightText: Copyright (c) 2024 Intel Corporation
19+
*
20+
* SPDX-License-Identifier: BSD-3-Clause
21+
*/
22+
23+
// Package v1 contains API Schema definitions for the bcs v1 API group
24+
// +kubebuilder:object:generate=true
25+
// +groupName=bcs.bcs.intel
26+
package v1
27+
28+
import (
29+
"k8s.io/apimachinery/pkg/runtime/schema"
30+
"sigs.k8s.io/controller-runtime/pkg/scheme"
31+
)
32+
33+
var (
34+
// GroupVersion is group version used to register these objects
35+
GroupVersion = schema.GroupVersion{Group: "bcs.bcs.intel", Version: "v1"}
36+
37+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
38+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
39+
40+
// AddToScheme adds the types in this group-version to the given scheme.
41+
AddToScheme = SchemeBuilder.AddToScheme
42+
)

0 commit comments

Comments
 (0)