Apply grafana dashboard sidecare

This commit is contained in:
Seth Call 2025-12-07 15:37:46 -06:00
parent 8c30544be7
commit 37fccf13be
4 changed files with 45 additions and 8 deletions

View File

@ -12,6 +12,19 @@ You should regenerate `all-crds.yaml` by running `scripts/update-crds.sh` when:
1. **Upgrading the `kube-prometheus-stack` Helm chart**: If you bump the chart version in `k8s/monitoring/Chart.yaml` and update the dependencies, you must also update the CRDs to match the new version.
2. **Missing CRD fields**: If you encounter errors like `field not declared in schema` during ArgoCD syncs, it likely means the installed CRDs are outdated.
3. **Apply the CRDs**:
Since Helm does not manage CRD upgrades, you must apply the updated CRDs manually. You may need `--force-conflicts` if ArgoCD previously managed these resources:
```bash
kubectl apply --server-side --force-conflicts -f k8s/all-crds.yaml
```
4. **Commit and Push**:
Commit the updated `k8s/all-crds.yaml` to the repository.
```bash
git add k8s/all-crds.yaml
git commit -m "Update Prometheus CRDs"
git push
```
### How to update

View File

@ -184,6 +184,11 @@ kube-prometheus-stack:
root_url: "%(protocol)s://%(domain)s/grafana/"
enable_gzip: "true"
serve_from_sub_path: true
sidecar:
dashboards:
enabled: true
label: grafana_dashboard
searchNamespace: ALL
additionalDataSources:
- name: Loki
type: loki

View File

@ -184,6 +184,11 @@ kube-prometheus-stack:
root_url: "%(protocol)s://%(domain)s/grafana/"
enable_gzip: "true"
serve_from_sub_path: true
sidecar:
dashboards:
enabled: true
label: grafana_dashboard
searchNamespace: ALL
additionalDataSources:
- name: Loki
type: loki

View File

@ -8,14 +8,23 @@ if [ -z "$ENVIRONMENT" ]; then
exit 1
fi
# Define cleanup function to revert changes to applications.yaml
cleanup() {
if [ -f k8s/argocd/base/applications.yaml.bak ]; then
echo "Reverting k8s/argocd/base/applications.yaml..."
mv k8s/argocd/base/applications.yaml.bak k8s/argocd/base/applications.yaml
fi
}
trap cleanup EXIT
if [ "$ENVIRONMENT" == "staging" ]; then
echo "Deploying to STAGING..."
# Source activation script
if [ -f ~/bin/activate_stg ]; then
source ~/bin/activate_stg
if [ -f ~/bin/activate-stg ]; then
source ~/bin/activate-stg
else
echo "Error: ~/bin/activate_stg not found."
echo "Error: ~/bin/activate-stg not found."
exit 1
fi
@ -26,10 +35,15 @@ if [ "$ENVIRONMENT" == "staging" ]; then
fi
echo "Using branch: $BITBUCKET_BRANCH"
# Template argocd/base/applications.yaml
# Template argocd/base/applications.yaml
echo "Templating k8s/argocd/base/applications.yaml..."
envsubst < k8s/argocd/base/applications.yaml > k8s/argocd/base/applications.yaml.tmp
mv k8s/argocd/base/applications.yaml.tmp k8s/argocd/base/applications.yaml
# Backup original file
cp k8s/argocd/base/applications.yaml k8s/argocd/base/applications.yaml.bak
# Perform substitution
envsubst < k8s/argocd/base/applications.yaml.bak > k8s/argocd/base/applications.yaml
# Apply Kustomize
echo "Applying Kustomize for staging..."
@ -46,10 +60,10 @@ elif [ "$ENVIRONMENT" == "production" ]; then
echo "Deploying to PRODUCTION..."
# Source activation script
if [ -f ~/bin/activate_prd ]; then
source ~/bin/activate_prd
if [ -f ~/bin/activate-prd ]; then
source ~/bin/activate-prd
else
echo "Error: ~/bin/activate_prd not found."
echo "Error: ~/bin/activate-prd not found."
exit 1
fi