Your Spotify
Your Spotify is a fun little app that lets you track your Spotify usage. You do need to obtain a Spotify API key, but that is a very easy process
Product: Your Spotify
Install Type: Manifest Files
Container Image: Linuxserver
Installation Details
While there are no official Kubernetes instructions for Your Sporify, we can adapt the Your Spotify Docker Install Instructions to guide us in creating the appropriate manifests. I have also opted to use the Linuxserver image for this deployment. Because this deployment uses Mongo for storage, we do not need to configure any additional storage options.
Now let's create the files we'll need to configure Your Spotify in Kubernetes
The following manifest files assume you will want to install this to a namespace named media, an nginx ingress named nginx, and Cert Manager configured to use the ACME provider Let's Encrypt. Please adjust for your particular needs.
00-media-namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: media
labels:
name: media
01-config.yaml
This will define the environment variables for your Your Spotify installation. You should consult the Your Spotify Environment Docs for configuration options. I configure some general settings and database connections but there are many other options can also be configured.
I am currently using a central Mongo database for my installation. You will need to adjust or remove these options as needed. Also, you will see that some more sensitive items are stored as a Secret rather than a ConfigMap. Also, don't forget to Setup the Application on Spotify to obtain the Spotify Public and Secret.
---
apiVersion: v1
kind: ConfigMap
metadata:
name: yourspotify-configs
namespace: media
data:
TZ: "America/New_York"
TIMEZONE: "America/New_York"
APP_URL: "https://your-spotify.server.url"
MONGO_NO_ADMIN_RIGHTS: "true"
---
apiVersion: v1
kind: Secret
metadata:
name: yourspotify-secrets
namespace: media
type: Opaque
stringData:
SPOTIFY_PUBLIC: "ObtainedFromSpotify"
SPOTIFY_SECRET: "ObtainedFromSpotify"
MONGO_ENDPOINT: "mongodb://your_spotify_user:your_spotify_password@your.mongodb.server:27017/your_spotify"
03-deploy.yaml
The Deployment brings together the configuration and storage with the container image.
apiVersion: apps/v1
kind: Deployment
metadata:
name: yourspotify
namespace: media
labels:
app: yourspotify
app.kubernetes.io/name: yourspotify
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: yourspotify
template:
metadata:
labels:
app: yourspotify
app.kubernetes.io/name: yourspotify
spec:
containers:
- name: yourspotify
image: linuxserver/your_spotify
imagePullPolicy: Always
ports:
- containerPort: 80
name: http
envFrom:
- configMapRef:
name: yourspotify-configs
- secretRef:
name: yourspotify-secrets
04-service.yaml
The service will help expose the pod for use. I leverage ClusterIP with an Ingress, but you could use a LoadBalancer type (with something like MetalLB to expose Photoprism on an IP outside of your cluster directly.
kind: Service
apiVersion: v1
metadata:
name: yourspotify-service
namespace: media
spec:
selector:
app: yourspotify
ports:
- protocol: TCP
port: 80
targetPort: 80
name: http
type: ClusterIP
05-ingress.yaml
An Ingress is one way to expose your services and can allow you to use Cert Manager to create TLS certificates for your site as well. In the annotations: {} section
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: yourspotify-ingress
namespace: media
annotations:
cert-manager.io/cluster-issuer: 'letsencrypt'
spec:
ingressClassName: nginx
rules:
- host: yourspotify.server.url
paths:
- path: /
pathType: Prefix
backend:
service:
name: yourspotify-service
port:
number: 80
tls:
- hosts:
- yourspotify.server.url
secretName: yourspotify-ext-tls
build-yourspotify.sh
Now that we have prepared our manifests we need to deploy them to the cluster with kubectl. I create shell scripts for all my deployments so I can quickly redeploy if I make any adjustments. The below script does assume you have configured kubectl properly already.
#!/bin/bash
kubectl apply -f 00-media-namespace.yaml \
-f 01-config.yaml \
-f 03-deploy.yaml \
-f 04-service.yaml \
-f 05-ingress.yaml
We can deploy the manifests for Your Spotify to the Kubernetes cluster by executing the following:
chmod 755 build-yourspotify.sh
./build-yourspotify.sh
I keep all my manifests, scripts, and helm charts in a private git repository for version control and archival storage While it is certainly not required to deploy Your Spotify, it has made my life a little easier.