carlosedp / cluster-monitoring

Cluster monitoring stack for clusters based on Prometheus Operator
MIT License
740 stars 200 forks source link

ArgoCD Deployment of the stack #170

Closed mickkael closed 6 months ago

mickkael commented 1 year ago

Describe the bug Failure in deploying cluster-monitoring through ArgoCD

Troubleshooting

  1. Which kind of Kubernetes cluster are you using? (Kubernetes, K3s, etc) K3s 1.23
  2. Are all pods in "Running" state? If any is in CrashLoopback or Error, check it's logs. It's before the deployment. I have a working deployment, but would prefer to have the code deployed in a gitops way rather than building with make manually everytime I want to deploy a new version of the images.

ArgoCD (2.4.17) is throwing this error: Unable to create application: application spec for observability.app is invalid: InvalidSpecError: Unable to generate manifests in observability: rpc error: code = FailedPrecondition desc = Failed to unmarshal generated json "base_operator_stack.jsonnet": Object 'Kind' is missing in '{ }'

Customizations

  1. Did you customize vars.jsonnet? Put the contents below:
# vars.jsonnet content
{
  _config+:: {
    namespace: 'observability',
  },
  // Enable or disable additional modules
  modules: [
    {
      // After deployment, run the create_gmail_auth.sh script from scripts dir.
      name: 'smtpRelay',
      enabled: true,
      file: import 'modules/smtp_relay.jsonnet',
    },
    {
      name: 'armExporter',
      enabled: true,
      file: import 'modules/arm_exporter.jsonnet',
    },
    {
      name: 'upsExporter',
      enabled: false,
      file: import 'modules/ups_exporter.jsonnet',
    },
    {
      name: 'metallbExporter',
      enabled: true,
      file: import 'modules/metallb.jsonnet',
    },
    {
      name: 'nginxExporter',
      enabled: false,
      file: import 'modules/nginx.jsonnet',
    },
    {
      name: 'traefikExporter',
      enabled: true,
      file: import 'modules/traefik.jsonnet',
    },
    {
      name: 'elasticExporter',
      enabled: false,
      file: import 'modules/elasticsearch_exporter.jsonnet',
    },
    {
      name: 'speedtestExporter',
      enabled: true,
      file: import 'modules/speedtest_exporter.jsonnet',
    },
  ],

  k3s: {
    enabled: true,
    master_ip: ['192.168.1.15'],
  },

  // Domain suffix for the ingresses
  suffixDomain: '192.168.99.100.nip.io',
  // Additional domain suffixes for the ingresses.
  // For example suffixDomain could be an external one and this a local domain.
  additionalDomains: [],
  // If TLSingress is true, a self-signed HTTPS ingress with redirect will be created
  TLSingress: true,
  // If UseProvidedCerts is true, provided files will be used on created HTTPS ingresses.
  // Use a wildcard certificate for the domain like ex. "*.192.168.99.100.nip.io"
  UseProvidedCerts: false,
  TLSCertificate: importstr 'server.crt',
  TLSKey: importstr 'server.key',

  // Persistent volume configuration
  enablePersistence: {
    // Setting these to false, defaults to emptyDirs.
    prometheus: false,
    grafana: false,
    // If using a pre-created PV, fill in the names below. If blank, they will use the default StorageClass
    prometheusPV: '',
    grafanaPV: '',
    // If required to use a specific storageClass, keep the PV names above blank and fill the storageClass name below.
    storageClass: '',
    // Define the PV sizes below
    prometheusSizePV: '2Gi',
    grafanaSizePV: '20Gi',
  },

  // Configuration for Prometheus deployment
  prometheus: {
    retention: '15d',
    scrapeInterval: '30s',
    scrapeTimeout: '30s',
  },
  grafana: {
    // Grafana "from" email
    from_address: 'myemail@gmail.com',
    // Plugins to be installed at runtime.
    //Ex. plugins: ['grafana-piechart-panel', 'grafana-clock-panel'],
    plugins: [],
    //Ex. env: [ { name: 'http_proxy', value: 'host:8080' } ]
    env: [],
  },
}

Additional context This is the ArgoCD App definition, pretty basic.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: obervability.app
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  destination:
    name: ''
    namespace: observability
    server: 'https://kubernetes.default.svc'
  source:
    path: observability
    repoURL: 'git@github.com:username/repo.git'
    targetRevision: HEAD
    directory:
      recurse: true
      jsonnet:
        extVars:
  project: default
carlosedp commented 6 months ago

I don't know ArgoCD well enough to know if it can read the jsonnet files but I believe you should add the YAML generation to the pipeline and make Argo read from there. Apparently not an issue in the monitoring stack.