Deploy the plex-media-server helm chart on Opensshift
TypeScriptTo deploy the Plex Media Server using a Helm chart on an OpenShift cluster with Pulumi, you will need to write a Pulumi program that interacts with the Kubernetes API to apply the Helm chart. Pulumi provides the Kubernetes provider which can be used to define resources on a Kubernetes cluster.
The program below is written in TypeScript and requires Node.js and Pulumi to be installed on your system. It leverages the
@pulumi/kubernetes
package from Pulumi's Kubernetes provider to deploy a Helm chart on an existing OpenShift cluster.You'll need to have
kubectl
configured to access your OpenShift cluster, or you need the appropriate kubeconfig file and context to be set for the cluster where you wish to deploy Plex Media Server.Here's a Pulumi program to achieve this goal:
import * as k8s from "@pulumi/kubernetes"; // You need to have the OpenShift cluster's kubeconfig set up correctly for this to work. // It can be passed as an argument to Provider or picked up from the default location (`~/.kube/config`). // Create a provider resource to specify the cluster where the Helm chart will be installed. const provider = new k8s.Provider("openshift-k8s", { // Assuming the default context in your kubeconfig is pointing to your OpenShift cluster }); // Deploy the Plex Media Server helm chart onto your OpenShift cluster const plexChart = new k8s.helm.sh.v3.Chart("plex-media-server", { chart: "plex-media-server", // The name of the chart version: "1.0.0", // Specify the version of the Helm chart namespace: "default", // Namespace to deploy into, change if you want it in a different one fetchOpts: { // This option depends on where the Plex Media Server Helm chart is hosted, such as a URL or repo. repo: "https://charts.example.com/", // Replace with the actual Helm chart repo URL }, }, { provider }); // Export any properties you may want to know after deployment, like the service URL export const plexServiceUrl = plexChart.getResourceProperty("v1/Service", "plex-media-server", "status");
Here's what each part of the code does:
-
We import the
@pulumi/kubernetes
package to use Pulumi's Kubernetes provider. -
We create a
Provider
object which tells Pulumi which Kubernetes cluster to use when deploying resources. By default, it uses the current context set in your kubeconfig, which should point to your OpenShift cluster. -
We deploy the Plex Media Server using the
Chart
class from Pulumi's Kubernetes provider. Thechart
parameter specifies the name of the Helm chart we intend to deploy (which should be replaced with the actual name if different). Theversion
parameter can be used to specify a particular version of the Helm chart. You will need to replace therepo
option with the link to the Helm chart repository where the Plex Media Server chart is hosted. Thenamespace
parameter specifies which Kubernetes namespace the chart will be installed into; this defaults to "default" but can be changed as needed. -
As a final step, we export the service URL, which you can use to access the Plex Media Server in your OpenShift cluster after it's spun up.
Please ensure that you replace the placeholders such as chart version and repository with the actual values that apply to the Plex Media Server Helm chart.
To apply the above configuration to your OpenShift cluster, you'd save the code in a file (e.g.,
index.ts
), then runpulumi up
from the command line in the same directory as your file. This will start the deployment process managed by Pulumi.-