Skip to content

Commit

Permalink
🧑‍💻(project:nex·rpi): Configure Tilt to quickly iterate on Glance con…
Browse files Browse the repository at this point in the history
…figuration

Signed-off-by: Alexandre Nicolaie <xunleii@users.noreply.github.com>
  • Loading branch information
xunleii committed Sep 30, 2024
1 parent 3364698 commit ba03dd1
Show file tree
Hide file tree
Showing 4 changed files with 280 additions and 0 deletions.
24 changes: 24 additions & 0 deletions projects/nex.rpi/src/.justfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,27 @@ kubernetes_apply environment="production":
KUBECTL_APPLYSET=true kubectl apply --kustomize 'clusters/{{environment}}' --prune --server-side --applyset=clusterapplysets.kubernetes.chezmoi.sh/nex.rpi --force-conflicts
alias apply := kubernetes_apply

# -- Local development environment
[doc("Run the local development environment")]
dev: kubernetes_cluster_create
tilt up

[doc("Create a local Kubernetes cluster")]
@kubernetes_cluster_create:
just {{ if env("DEVCONTAINER_NETWORK", "") != "" { "kubernetes_cluster_create_devcontainer" } else { "kubernetes_cluster_create_local" } }}

[private]
[doc("Create a local Kubernetes cluster accessible from the host")]
kubernetes_cluster_create_local:
k3d cluster create --no-lb {{kubernetes_cluster_name}} || true

[private]
[doc("Create a local Kubernetes cluster accessible from the devcontainer")]
kubernetes_cluster_create_devcontainer:
k3d cluster create --no-lb --network {{ env("DEVCONTAINER_NETWORK") }} {{kubernetes_cluster_name}} || true
kubectl config set-cluster k3d-{{kubernetes_cluster_name}} --server=https://k3d-{{kubernetes_cluster_name}}-server-0:6443

[doc("Delete the local Kubernetes cluster")]
kubernetes_cluster_teardown:
k3d cluster delete {{kubernetes_cluster_name}} || true
alias dev_teardown := kubernetes_cluster_teardown
53 changes: 53 additions & 0 deletions projects/nex.rpi/src/Tiltfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Welcome to nr-dashboard Tilt!
# This Tiltfile is used to play with the Glance (the application
# that powers the nr-dashboard) and configure it as quickly as
# possible.
print("""
-----------------------------------------------------------------
Welcome to nex·rpi Tilt!
This Tiltfile is used to play with the nex·rpi project and
configure it in a easy way.
It uses Kustomize to manage Kubernetes resources through the
`apps/*/live/dev` configurations.
-----------------------------------------------------------------
""".strip())

# Deploy Kubernetes resources using Kustomize
# nex·rpi uses Kustomize to manage Kubernetes resources through the
# `apps/*/live/dev` configurations.
#
# In order to avoid deploying the whole project, Tilt will only
# deploy what the end-user is working on.
load('ext://uibutton', 'cmd_button')

# `nr-dashboard` namespace
def nr_dashboard():
app_dir = '{tiltfile_dir}/apps/nr-dashboard'.format(tiltfile_dir=config.main_dir)

nr_dashboard_yaml = kustomize('{app_dir}/live/dev'.format(app_dir=app_dir))
nr_glance_configmaps = ['{}:configmap'.format(r["metadata"]["name"]) for r in decode_yaml_stream(nr_dashboard_yaml) if r["kind"] == "ConfigMap" and r["metadata"]["name"].startswith("glance-configuration")]
if len(nr_glance_configmaps) == 0:
fail('⚠️ No glance configuration found. Please make sure to create one in the `configurations/glance.yaml` file.')

watch_file('{app_dir}/live/dev'.format(app_dir=app_dir))
k8s_yaml(nr_dashboard_yaml)
k8s_resource('glance',
port_forwards=[8080],
auto_init=False,
objects=nr_glance_configmaps,
trigger_mode=TRIGGER_MODE_MANUAL)

# Customise Tilt UI to syncronize Glance development configuration to the
# production one
cmd_button('sync_configuration',
argv=[
'cp',
'{app_dir}/live/dev/configurations/glance.yaml'.format(app_dir=app_dir),
'{app_dir}/live/production/configurations/glance.yaml'.format(app_dir=app_dir)
],
icon_name='sync_alt',
resource='glance',
text='Sync configuration to production',
)
nr_dashboard()
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
---
pages:
- name: Startpage
width: slim
hide-desktop-navigation: true
center-vertically: true
columns:
- size: full
widgets:
- type: search
autofocus: true
bangs:
- title: Google
shortcut: "!g"
url: https://www.google.com/search?q=%s


- type: monitor
cache: 1m
title: Services
sites:
- title: Jellyfin
url: https://yourdomain.com/
icon: si:jellyfin
- title: Gitea
url: https://yourdomain.com/
icon: si:gitea
- title: qBittorrent # only for Linux ISOs, of course
url: https://yourdomain.com/
icon: si:qbittorrent
- title: Immich
url: https://yourdomain.com/
icon: si:immich
- title: AdGuard Home
url: https://yourdomain.com/
icon: si:adguard
- title: Vaultwarden
url: https://yourdomain.com/
icon: si:vaultwarden

- type: bookmarks
groups:
- title: General
links:
- title: Gmail
url: https://mail.google.com/mail/u/0/
- title: Amazon
url: https://www.amazon.com/
- title: Github
url: https://github.com/
- title: Entertainment
links:
- title: YouTube
url: https://www.youtube.com/
- title: Prime Video
url: https://www.primevideo.com/
- title: Disney+
url: https://www.disneyplus.com/
- title: Social
links:
- title: Reddit
url: https://www.reddit.com/
- title: Twitter
url: https://twitter.com/
- title: Instagram
url: https://www.instagram.com/
- name: Markets
columns:
- size: small
widgets:
- type: markets
title: Indices
markets:
- symbol: SPY
name: S&P 500
- symbol: DX-Y.NYB
name: Dollar Index

- type: markets
title: Crypto
markets:
- symbol: BTC-USD
name: Bitcoin
- symbol: ETH-USD
name: Ethereum

- type: markets
title: Stocks
sort-by: absolute-change
markets:
- symbol: NVDA
name: NVIDIA
- symbol: AAPL
name: Apple
- symbol: MSFT
name: Microsoft
- symbol: GOOGL
name: Google
- symbol: AMD
name: AMD
- symbol: RDDT
name: Reddit
- symbol: AMZN
name: Amazon
- symbol: TSLA
name: Tesla
- symbol: INTC
name: Intel
- symbol: META
name: Meta

- size: full
widgets:
- type: rss
title: News
style: horizontal-cards
feeds:
- url: https://feeds.bloomberg.com/markets/news.rss
title: Bloomberg
- url: https://moxie.foxbusiness.com/google-publisher/markets.xml
title: Fox Business
- url: https://moxie.foxbusiness.com/google-publisher/technology.xml
title: Fox Business

- type: group
widgets:
- type: reddit
show-thumbnails: true
subreddit: technology
- type: reddit
show-thumbnails: true
subreddit: wallstreetbets

- type: videos
style: grid-cards
collapse-after-rows: 3
channels:
- UCvSXMi2LebwJEM1s4bz5IBA # New Money
- UCV6KDgJskWaEckne5aPA0aQ # Graham Stephan
- UCAzhpt9DmG6PnHXjmJTvRGQ # Federal Reserve

- size: small
widgets:
- type: rss
title: News
limit: 30
collapse-after: 13
feeds:
- url: https://www.ft.com/technology?format=rss
title: Financial Times
- url: https://feeds.a.dj.com/rss/RSSMarketsMain.xml
title: Wall Street Journal
- name: Gaming
columns:
- size: small
widgets:
- type: twitch-top-games
limit: 20
collapse-after: 13
exclude:
- just-chatting
- pools-hot-tubs-and-beaches
- music
- art
- asmr

- size: full
widgets:
- type: group
widgets:
- type: reddit
show-thumbnails: true
subreddit: pcgaming
- type: reddit
subreddit: games

- type: videos
style: grid-cards
collapse-after-rows: 3
channels:
- UCNvzD7Z-g64bPXxGzaQaa4g # gameranx
- UCZ7AeeVbyslLM_8-nVy2B8Q # Skill Up
- UCHDxYLv8iovIbhrfl16CNyg # GameLinked
- UC9PBzalIcEQCsiIkq36PyUA # Digital Foundry

- size: small
widgets:
- type: reddit
subreddit: gamingnews
limit: 7
style: vertical-cards
12 changes: 12 additions & 0 deletions projects/nex.rpi/src/apps/nr-dashboard/live/dev/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: default

resources:
- ../../base/glance

configMapGenerator:
- name: glance-configuration
files:
- glance.yml=configurations/glance.yaml

0 comments on commit ba03dd1

Please sign in to comment.