forked from kubealex/k8s-mediaserver-operator
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First commit for k8s-mediaserver-operator
- Loading branch information
0 parents
commit fbc6d34
Showing
64 changed files
with
2,238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
bin | ||
|
||
# editor and IDE paraphernalia | ||
.idea | ||
*.swp | ||
*.swo | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Build the manager binary | ||
FROM quay.io/operator-framework/helm-operator:v1.1.0 | ||
|
||
ENV HOME=/opt/helm | ||
COPY watches.yaml ${HOME}/watches.yaml | ||
COPY helm-charts ${HOME}/helm-charts | ||
WORKDIR ${HOME} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Alessandro Rossi | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Current Operator version | ||
VERSION ?= 0.0.1 | ||
# Default bundle image tag | ||
BUNDLE_IMG ?= controller-bundle:$(VERSION) | ||
# Options for 'bundle-build' | ||
ifneq ($(origin CHANNELS), undefined) | ||
BUNDLE_CHANNELS := --channels=$(CHANNELS) | ||
endif | ||
ifneq ($(origin DEFAULT_CHANNEL), undefined) | ||
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL) | ||
endif | ||
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) | ||
|
||
# Image URL to use all building/pushing image targets | ||
IMG ?= controller:latest | ||
|
||
all: docker-build | ||
|
||
# Run against the configured Kubernetes cluster in ~/.kube/config | ||
run: helm-operator | ||
$(HELM_OPERATOR) run | ||
|
||
# Install CRDs into a cluster | ||
install: kustomize | ||
$(KUSTOMIZE) build config/crd | kubectl apply -f - | ||
|
||
# Uninstall CRDs from a cluster | ||
uninstall: kustomize | ||
$(KUSTOMIZE) build config/crd | kubectl delete -f - | ||
|
||
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config | ||
deploy: kustomize | ||
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} | ||
$(KUSTOMIZE) build config/default | kubectl apply -f - | ||
|
||
# Undeploy controller in the configured Kubernetes cluster in ~/.kube/config | ||
undeploy: kustomize | ||
$(KUSTOMIZE) build config/default | kubectl delete -f - | ||
|
||
# Build the docker image | ||
docker-build: | ||
docker build . -t ${IMG} | ||
|
||
# Push the docker image | ||
docker-push: | ||
docker push ${IMG} | ||
|
||
PATH := $(PATH):$(PWD)/bin | ||
SHELL := env PATH=$(PATH) /bin/sh | ||
OS = $(shell uname -s | tr '[:upper:]' '[:lower:]') | ||
ARCH = $(shell uname -m | sed 's/x86_64/amd64/') | ||
OSOPER = $(shell uname -s | tr '[:upper:]' '[:lower:]' | sed 's/darwin/apple-darwin/' | sed 's/linux/linux-gnu/') | ||
ARCHOPER = $(shell uname -m ) | ||
|
||
kustomize: | ||
ifeq (, $(shell which kustomize 2>/dev/null)) | ||
@{ \ | ||
set -e ;\ | ||
mkdir -p bin ;\ | ||
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v3.5.4/kustomize_v3.5.4_$(OS)_$(ARCH).tar.gz | tar xzf - -C bin/ ;\ | ||
} | ||
KUSTOMIZE=$(realpath ./bin/kustomize) | ||
else | ||
KUSTOMIZE=$(shell which kustomize) | ||
endif | ||
|
||
helm-operator: | ||
ifeq (, $(shell which helm-operator 2>/dev/null)) | ||
@{ \ | ||
set -e ;\ | ||
mkdir -p bin ;\ | ||
curl -LO https://github.com/operator-framework/operator-sdk/releases/download/v1.1.0/helm-operator-v1.1.0-$(ARCHOPER)-$(OSOPER) ;\ | ||
mv helm-operator-v1.1.0-$(ARCHOPER)-$(OSOPER) ./bin/helm-operator ;\ | ||
chmod +x ./bin/helm-operator ;\ | ||
} | ||
HELM_OPERATOR=$(realpath ./bin/helm-operator) | ||
else | ||
HELM_OPERATOR=$(shell which helm-operator) | ||
endif | ||
|
||
# Generate bundle manifests and metadata, then validate generated files. | ||
.PHONY: bundle | ||
bundle: kustomize | ||
operator-sdk generate kustomize manifests -q | ||
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) | ||
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) | ||
operator-sdk bundle validate ./bundle | ||
|
||
# Build the bundle image. | ||
.PHONY: bundle-build | ||
bundle-build: | ||
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
domain: com | ||
layout: helm.sdk.operatorframework.io/v1 | ||
projectName: k8s-mediaserver-operator | ||
resources: | ||
- group: kubealex | ||
kind: K8SMediaserver | ||
version: v1 | ||
version: 3-alpha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
## k8s-mediaserver-operator - Your all-in-one resource for your media needs! | ||
|
||
I am so happy to announce the first release of the **k8s-mediaserver-operator**, a project that mixes up some of the mainstream tools for your media needs. | ||
|
||
The Custom Resource that is implemented, allows you to create a fully working and complete media server on #kubernetes, based on: | ||
|
||
[Plex Media Server](https://www.plex.tv/ "Plex Media Server") - A complete and fully funtional mediaserver that allows you to render in a webUI your movies, TV Series, podcasts, video streams. | ||
|
||
[Sonarr](https://sonarr.tv/ "Sonarr") - A TV series and show tracker, that allows the integration with download managers for searching and retrieving TV Series, organizing them, schedule notifications when an episode comes up and much more. | ||
|
||
[Radarr](https://radarr.video/ "Radarr") - The same a **Sonarr**, but for movies! | ||
|
||
[Jackett](https://github.com/Jackett/Jackett "Jackett") - An API interface that keeps easy your life interacting with trackers for torrents. | ||
|
||
[Transmission](https://transmissionbt.com/ "Transmission") - A fast, easy and reliable torrent client. | ||
|
||
All the container images used by the operator are from [linuxserver](https://github.com/linuxserver) - [linuxserver.io](https://www.linuxserver.io/ "linuxserver.io") | ||
|
||
## Introduction | ||
|
||
I started working on this project because I was tired of using the 'containerized' version with docker/podman-compose, and I wanted to experiment a bit both with helm and operators. | ||
|
||
It is quite simple to use, and very minimalistic, with customizations that are strictly related to usability and access, rather than complex customizations, even if, maybe in the future, we could add it! | ||
|
||
Each container has its *init container* in order to initialize configurations on the PV before starting the actual pod and avoid to restart the pods. | ||
|
||
## QuickStart | ||
|
||
The operator and the CR are already configured with some defaults settings to make you jump and go with it. | ||
|
||
All you need is: | ||
|
||
- A namespace where you want to put your CR and all the pods that will spawn | ||
- Being able to provision an RWX PV where to store configurations, downloads, and all related stuff (suggested > 200GB). PV could be created manually and/or dynamically provisioned. | ||
|
||
First install the CRD and the operator: | ||
|
||
kubectl apply -f k8s-mediaserver-operator.yml | ||
|
||
Then you are good to go with the CR: | ||
|
||
kubectl apply -f k8s-mediaserver.yml | ||
|
||
In seconds, you will be ready to use your applications! | ||
|
||
## The mediaserver CR | ||
The CR is quite simple to configure, and I tried to keep the number of parameters low to avoid confusion, but still letting some customization to fit the resource inside your cluster. | ||
|
||
# General config | ||
|
||
| Config path | Meaning | Default | | ||
| ------------ | ------------ | ------------ | | ||
| general.ingress_host | The hostname to use in ingress definition, this will be the hostname where the applications will be exposed | k8s-mediaserver.k8s.test | | ||
| general.plex_ingress_host | The hostname to use for **PLEX** as it must be exposed on a / dedicated path | k8s-plex.k8s.test | | ||
| general.pgid | The GID for the process | 1000 | | ||
| general.puid | The UID for the process | 1000 | | ||
| general.nodeSelector | Node Selector for all the pods | {} | | ||
| general.storage.nfs | Specifies if the PV should be configured as a NFS export | false | | ||
| general.storage.nfsPath | If PV type is NFS, specifies the path of the export | "" | | ||
| general.storage.nfsServer | If PV type is NFS, specifies the server exporting the volume | "" | | ||
| general.storage.pvcName | Name of the persistenVolumeClaim configured in deployments | mediaserver-pvc | | ||
| general.storage.pvcStorageClass | Specifies a storageClass for the PVC | {} | | ||
| general.storage.size | Size of the persistenVolume | 50Gi | | ||
|
||
# Plex | ||
|
||
| Config path | Meaning | Default | | ||
| ------------ | ------------ | ------------ | | ||
|plex.claim | **IMPORTANT** Token from your account, needed to claim the server | CHANGEME | | ||
|plex.replicaCount | Number of replicas serving plex | 1 | | ||
|plex.container.port | The port in use by the container | 32400 | | ||
|plex.service.type | The kind of Service (ClusterIP/NodePort/LoadBalancer) | ClusterIP | | ||
|plex.service.port | The port assigned to the service | 32400 | | ||
|plex.service.nodePort | In case of service.type NodePort, the nodePort to use | "" | | ||
|plex.service.extraLBService | If true, creates an additional LoadBalancer service with '-lb' suffix (requires a cloud provider or metalLB) | false | | ||
|plex.ingress.enabled | If true, creates the ingress resource for the application | true | | ||
|plex.ingress.annotations | Additional field for annotations, if needed | {} | | ||
|plex.ingress.path | The path where the application is exposed | /plex | | ||
|plex.ingress.tls.enabled | If true, tls is enabled | false | | ||
|plex.ingress.tls.secretName | Name of the secret holding certificates for the secure ingress | "" | | ||
|
||
# Sonarr | ||
|
||
| Config path | Meaning | Default | | ||
| ------------ | ------------ | ------------ | | ||
| sonarr.container.port | The port in use by the container | 8989 | | ||
| sonarr.service.type | The kind of Service (ClusterIP/NodePort/LoadBalancer) | ClusterIP | | ||
| sonarr.service.port | The port assigned to the service | 8989 | | ||
| sonarr.service.nodePort | In case of service.type NodePort, the nodePort to use | "" | | ||
| sonarr.service.extraLBService | If true, creates an additional LoadBalancer service with '-lb' suffix (requires a cloud provider or metalLB) | false | ||
| sonarr.ingress.enabled | If true, creates the ingress resource for the application | true | | ||
| sonarr.ingress.annotations | Additional field for annotations, if needed | {} | | ||
| sonarr.ingress.path | The path where the application is exposed | /sonarr | | ||
| sonarr.ingress.tls.enabled | If true, tls is enabled | false | | ||
| sonarr.ingress.tls.secretName | Name of the secret holding certificates for the secure ingress | "" | | ||
|
||
# Radarr | ||
|
||
| Config path | Meaning | Default | | ||
| ------------ | ------------ | ------------ | | ||
| radarr.container.port | The port in use by the container | 7878 | | ||
| radarr.service.type | The kind of Service (ClusterIP/NodePort/LoadBalancer) | ClusterIP | | ||
| radarr.service.port | The port assigned to the service | 7878 | | ||
| radarr.service.nodePort | In case of service.type NodePort, the nodePort to use | "" | | ||
| radarr.service.extraLBService | If true, creates an additional LoadBalancer service with '-lb' suffix (requires a cloud provider or metalLB) | false | | ||
| radarr.ingress.enabled | If true, creates the ingress resource for the application | true | | ||
| radarr.ingress.annotations | Additional field for annotations, if needed | {} | | ||
| radarr.ingress.path | The path where the application is exposed | /radarr | | ||
| radarr.ingress.tls.enabled | If true, tls is enabled | false | | ||
| radarr.ingress.tls.secretName | Name of the secret holding certificates for the secure ingress | "" | | ||
|
||
# Jackett | ||
|
||
| Config path | Meaning | Default | | ||
| ------------ | ------------ | ------------ | | ||
| jackett.container.port | The port in use by the container | 9117 | | ||
| jackett.service.type | The kind of Service (ClusterIP/NodePort/LoadBalancer) | ClusterIP | | ||
| jackett.service.port | The port assigned to the service | 9117 | | ||
| jackett.service.nodePort | In case of service.type NodePort, the nodePort to use | "" | | ||
| jackett.service.extraLBService | If true, it creates an additional LoadBalancer service with '-lb' suffix (requires a cloud provider or metalLB) | false | | ||
| jackett.ingress.enabled | If true, creates the ingress resource for the application | true | | ||
| jackett.ingress.annotations | Additional field for annotations, if needed | {} | | ||
| jackett.ingress.path | The path where the application is exposed | /jackett | | ||
| jackett.ingress.tls.enabled | If true, tls is enabled | false | | ||
| jackett.ingress.tls.secretName | Name of the secret holding certificates for the secure ingress | "" | | ||
|
||
# Transmission | ||
|
||
| Config path | Meaning | Default | | ||
| ------------ | ------------ | ------------ | | ||
| transmission.container.port | The port in use by the container | 9091 | | ||
| transmission.service.type | The kind of Service (ClusterIP/NodePort/LoadBalancer) | ClusterIP | | ||
| transmission.service.port | The port assigned to the service | 9091 | | ||
| transmission.service.nodePort | In case of service.type NodePort, the nodePort to use | "" | | ||
| transmission.service.extraLBService | If true, creates an additional LoadBalancer service with '-lb' suffix (requires a cloud provider or metalLB) | false | | ||
| transmission.ingress.enabled | If true, creates the ingress resource for the application | true | | ||
| transmission.ingress.annotations | Additional field for annotations, if needed | {} | | ||
| transmission.ingress.path | The path where the application is exposed | /transmission | | ||
| transmission.ingress.tls.enabled | If true, tls is enabled | false | | ||
| transmission.ingress.tls.secretName | Name of the secret holding certificates for the secure ingress | "" | | ||
|
||
## About the project | ||
|
||
This project is intended as an exercise, and absolutely for fun. Don't use it to commit piracy. | ||
|
||
Also feel free to contribute and extend it! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: k8smediaservers.kubealex.com | ||
spec: | ||
group: kubealex.com | ||
names: | ||
kind: K8SMediaserver | ||
listKind: K8SMediaserverList | ||
plural: k8smediaservers | ||
singular: k8smediaserver | ||
scope: Namespaced | ||
versions: | ||
- name: v1 | ||
schema: | ||
openAPIV3Schema: | ||
description: K8SMediaserver is the Schema for the k8smediaservers API | ||
properties: | ||
apiVersion: | ||
description: 'APIVersion defines the versioned schema of this representation | ||
of an object. Servers should convert recognized schemas to the latest | ||
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' | ||
type: string | ||
kind: | ||
description: 'Kind is a string value representing the REST resource this | ||
object represents. Servers may infer this from the endpoint the client | ||
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' | ||
type: string | ||
metadata: | ||
type: object | ||
spec: | ||
description: Spec defines the desired state of K8SMediaserver | ||
type: object | ||
x-kubernetes-preserve-unknown-fields: true | ||
status: | ||
description: Status defines the observed state of K8SMediaserver | ||
type: object | ||
x-kubernetes-preserve-unknown-fields: true | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# This kustomization.yaml is not intended to be run by itself, | ||
# since it depends on service name and namespace that are out of this kustomize package. | ||
# It should be run by config/default | ||
resources: | ||
- bases/kubealex.com_k8smediaservers.yaml | ||
# +kubebuilder:scaffold:crdkustomizeresource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Adds namespace to all resources. | ||
namespace: k8s-mediaserver-operator-system | ||
|
||
# Value of this field is prepended to the | ||
# names of all resources, e.g. a deployment named | ||
# "wordpress" becomes "alices-wordpress". | ||
# Note that it should also match with the prefix (text before '-') of the namespace | ||
# field above. | ||
namePrefix: k8s-mediaserver-operator- | ||
|
||
# Labels to add to all resources and selectors. | ||
#commonLabels: | ||
# someName: someValue | ||
|
||
bases: | ||
- ../crd | ||
- ../rbac | ||
- ../manager | ||
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'. | ||
#- ../prometheus | ||
|
||
patchesStrategicMerge: | ||
# Protect the /metrics endpoint by putting it behind auth. | ||
# If you want your controller-manager to expose the /metrics | ||
# endpoint w/o any authn/z, please comment the following line. | ||
- manager_auth_proxy_patch.yaml |
Oops, something went wrong.