David Silwal
David Silwal

Reputation: 529

Error deploying .NET Aspire app to Kubernetes via GitHub Actions with Aspirate: "Object 'Kind' is missing in kustomization.yaml"

I’m trying to set up a GitHub Actions workflow to deploy a .NET Aspire application to a remote Kubernetes cluster using Aspirate. However, when applying the generated manifests, I get this error:

error: unable to decode "/home/***/k8s/github/workspace/AspireApp.AppHost/aspirate-output/kustomization.yaml": Object 'Kind' is missing in '{"generatorOptions":{"disableNameSuffixHash":true},"resources":["postgres","apiservice"]}'

Here’s my GitHub Actions workflow:

name: Deploy .NET Aspire to Remote Kubernetes Cluster with GHCR

on:
  push:
    branches:
      - main

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup .NET
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '9.0.x'

      - name: Install Aspirate
        run: dotnet tool install -g aspirate --prerelease

      - name: Generate Kubernetes Manifests
        run: |
          cd AspireApp.AppHost
          docker login ghcr.io -u ${{ secrets.GH_USER }} -p ${{ secrets.GH_TOKEN }}
          aspirate init -cr ghcr.io -ct latest --disable-secrets true --non-interactive
          aspirate generate --image-pull-policy Always --non-interactive --disable-secrets --include-dashboard false -pa username=admin -pa password=securepass -ct ${{ github.run_number }} -cr ghcr.io -crp davidsilwal
        env:
          DOTNET_CLI_TELEMETRY_OPTOUT: 1

      - name: Copy Manifests to Remote Host
        if: success()
        uses: appleboy/scp-action@master
        with:
          host: ${{ secrets.REMOTE_HOST }}
          username: ${{ secrets.REMOTE_USER }}
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          port: 22
          source: "/home/runner/work/AspireApp/AspireApp/AspireApp.AppHost/aspirate-output/*"
          target: "/home/ubuntu/k8s"

      - name: Apply Manifests with kubectl
        if: success()
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.REMOTE_HOST }}
          username: ${{ secrets.REMOTE_USER }}
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          port: 22
          script: |
            if ! command -v kubectl &> /dev/null; then
              curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
              chmod +x kubectl
              sudo mv kubectl /usr/local/bin/
            fi
            eval $(minikube docker-env)
            kubectl apply -f /home/ubuntu/k8s/github/workspace/AspireApp.AppHost/aspirate-output --validate=false

The error suggests that the kustomization.yaml file generated by Aspirate is missing the Kind field, which Kubernetes requires.

Questions:

I’m using .NET 9.0 and the latest prerelease version of Aspirate. Any help or working examples would be greatly appreciated!

Upvotes: -1

Views: 35

Answers (0)

Related Questions