krateoplatformops / krateo-docs

2 stars 2 forks source link

Bug "Create Fireworks App" tutorial #9

Closed andregri closed 1 year ago

andregri commented 1 year ago

I found some issues in the deployment of the fireworks app tutorial:

braghettos commented 1 year ago

Hi @andregri,

the Documentation and the Pipelines tabs return 404

Could you please check if the repository has been created?

the host in the ingress rule is fixed to fireworks.krateo.site even if it was changed during deployment configuration

That's really strange, could you please post the values.yaml file committed via Krateo?

andregri commented 1 year ago

I made two tests:

values.yaml of test 1 taken from Values tab:

apiVersion: deployment.krateo.io/v1alpha1
kind: FireworksApp
metadata:
  labels:
    crossplane.io/composite: firefire-fireworksapp
  name: firefire-fireworksapp
  uid: 1319382e-e266-4e50-8b0e-54d00314f245
spec:
  compositionRef:
    name: fireworksapp.deployment.krateo.io
  compositionRevisionRef:
    name: fireworksapp.deployment.krateo.io-9353ac7
  compositionUpdatePolicy: Automatic
  description: Fireworks App Deployment
  flat:
    destinationEndpoint: github.com
    host: fireworks-app.example.com
    name: firefire
    organizationName: krateoplatformops
    replicas: 3
  icon: fa-solid fa-fire
  links:
    - icon: fa-brands fa-git
      title: krateoplatformops/guest-fire-firefire
      url: https://github.com/krateoplatformops/guest-fire-firefire
  owner: mauro
  plugins:
    - endpointName: argocd
      icon: fa-solid fa-diagram-project
      name: resources
      type: argocd
      value: firefire-fireworksapp
    - endpointName: github
      icon: fa-solid fa-book
      name: documentation
      type: doc
      values:
        - '[krateoplatformops][guest-fire-firefire]README.md'
    - icon: fa-brands fa-docker
      name: kubernetes
      type: kubernetes
      value: deploymentId
    - endpointName: github
      icon: fa-solid fa-person-running
      name: pipelines
      type: pipeline
      values:
        - >-
          [krateoplatformops][guest-fire-firefire]Build Docker image for every
          commit
  resourceRefs:
    - apiVersion: kubernetes.crossplane.io/v1alpha1
      kind: ProviderConfig
      name: firefire-fireworksapp-provider-k8s-pc-in
    - apiVersion: kubernetes.crossplane.io/v1alpha1
      kind: Object
      name: firefire-fireworksapp-argocd-app-object
    - apiVersion: git.krateo.io/v1alpha1
      kind: ProviderConfig
      name: firefire-fireworksapp-provider-git-pc
    - apiVersion: kubernetes.crossplane.io/v1alpha1
      kind: Object
      name: firefire-fireworksapp-fireworksapp-values
    - apiVersion: git.krateo.io/v1alpha1
      kind: Repo
      name: firefire-fireworksapp-8qjg4
    - apiVersion: github.krateo.io/v1alpha1
      kind: ProviderConfig
      name: firefire-fireworksapp-provider-github-pc
    - apiVersion: github.krateo.io/v1alpha1
      kind: Repo
  tags:
    - fireworks
    - template
    - krateo
    - katy perry
  templateName: krateo-fireworks
  title: firefire
  values:
    endpointName: github.com
    fromRepo:
      organizationName: krateoplatformops
      repositoryName: krateo-template-fireworksapp
      schema: https
    host: fireworks-app.example.com
    namespace: krateo-system
    organizationName: krateoplatformops
    replicas: 3
    repositoryName: guest-fire-firefire
    toRepo:
      organizationName: krateoplatformops
      repositoryName: guest-fire-firefire
      schema: https

The values.yaml from Values tab is:

apiVersion: deployment.krateo.io/v1alpha1
kind: FireworksApp
metadata:
  labels:
    crossplane.io/composite: firefire2-fireworksapp
  name: firefire2-fireworksapp
  uid: 7cbade9c-5ad2-4244-b9a9-0c0b30aa88bf
spec:
  compositionRef:
    name: fireworksapp.deployment.krateo.io
  compositionRevisionRef:
    name: fireworksapp.deployment.krateo.io-9353ac7
  compositionUpdatePolicy: Automatic
  description: Fireworks App Deployment
  flat:
    destinationEndpoint: github.com
    host: fireworks-app.example.com
    name: firefire2
    organizationName: andregri
    replicas: 3
  icon: fa-solid fa-fire
  links:
    - icon: fa-brands fa-git
      title: andregri/guest-fire-firefire2
      url: https://github.com/andregri/guest-fire-firefire2
  owner: mauro
  plugins:
    - endpointName: argocd
      icon: fa-solid fa-diagram-project
      name: resources
      type: argocd
      value: firefire2-fireworksapp
    - endpointName: github
      icon: fa-solid fa-book
      name: documentation
      type: doc
      values:
        - '[andregri][guest-fire-firefire2]README.md'
    - icon: fa-brands fa-docker
      name: kubernetes
      type: kubernetes
      value: deploymentId
    - endpointName: github
      icon: fa-solid fa-person-running
      name: pipelines
      type: pipeline
      values:
        - '[andregri][guest-fire-firefire2]Build Docker image for every commit'
  resourceRefs:
    - apiVersion: kubernetes.crossplane.io/v1alpha1
      kind: ProviderConfig
      name: firefire2-fireworksapp-provider-k8s-pc-in
    - apiVersion: kubernetes.crossplane.io/v1alpha1
      kind: Object
      name: firefire2-fireworksapp-argocd-app-object
    - apiVersion: git.krateo.io/v1alpha1
      kind: ProviderConfig
      name: firefire2-fireworksapp-provider-git-pc
    - apiVersion: kubernetes.crossplane.io/v1alpha1
      kind: Object
      name: firefire2-fireworksapp-fireworksapp-values
    - apiVersion: git.krateo.io/v1alpha1
      kind: Repo
      name: firefire2-fireworksapp-p4nnm
    - apiVersion: github.krateo.io/v1alpha1
      kind: ProviderConfig
      name: firefire2-fireworksapp-provider-github-pc
    - apiVersion: github.krateo.io/v1alpha1
      kind: Repo
  tags:
    - fireworks
    - template
    - krateo
    - katy perry
  templateName: krateo-fireworks
  title: firefire2
  values:
    endpointName: github.com
    fromRepo:
      organizationName: krateoplatformops
      repositoryName: krateo-template-fireworksapp
      schema: https
    host: fireworks-app.example.com
    namespace: krateo-system
    organizationName: andregri
    replicas: 3
    repositoryName: guest-fire-firefire2
    toRepo:
      organizationName: andregri
      repositoryName: guest-fire-firefire2
      schema: https
braghettos commented 1 year ago

To create a repository on GitHub, you must provide an endpoint (https://docs.krateo.io/tutorials/add-endpoint/) that can access an organization (in your case, andregri).

The composition uses several providers, like provider-github and provider-git which should be installed by default with the Krateo CLI.

In your installation of Krateo PlatformOps, could you check if the previous providers are installed via kubectl get pkg or navigating the 'Packages' section in the UI?

If everything is correctly installed, could you inspect the Custom Resources created by Krateo with kubectl get managed?

andregri commented 1 year ago

The composition uses several providers, like provider-github and provider-git which should be installed by default with the Krateo CLI.

As shown below I don't have the provider-github installed by default:

$ kubectl get pkg
NAME                                                               INSTALLED   HEALTHY   PACKAGE                                                         AGE
configuration.pkg.crossplane.io/krateo-module-core-configuration   True        True      ghcr.io/krateoplatformops/krateo-module-core:latest             79m
configuration.pkg.crossplane.io/krateo-template-fireworksapp       True        True      ghcr.io/krateoplatformops/krateo-template-fireworksapp:latest   65m

NAME                                                  INSTALLED   HEALTHY   PACKAGE                                                         AGE
provider.pkg.crossplane.io/provider-argocd-endpoint   True        True      ghcr.io/krateoplatformops/provider-argocd-endpoint:v1.0.0       79m
provider.pkg.crossplane.io/provider-git               True        True      ghcr.io/krateoplatformops/provider-git:v1.2.5                   79m
provider.pkg.crossplane.io/provider-helm              True        True      xpkg.upbound.io/crossplane-contrib/provider-helm:v0.13.0        79m
provider.pkg.crossplane.io/provider-kubernetes        True        True      xpkg.upbound.io/crossplane-contrib/provider-kubernetes:v0.6.0   79m
braghettos commented 1 year ago

Ok so you can install the provider-github via UI (section 'Packages', + button on the top right, choose 'PROVIDER GITHUB' and install it) or via kubectl (i.e. https://github.com/krateoplatformops/provider-github/blob/main/examples/provider.yaml changing the appropriated values)

andregri commented 1 year ago

Yes I installed successfully the github provider from kubectl. I couldn't install it from the UI.

However, after creating the template and the deployment, Github complained about missing permissions in the token:

command error on refs/heads/main: refusing to allow a Personal Access Token to create or update workflow `.github/workflows/docker-build.yaml` without `workflow` scope

I added the workflow scope to the token (I think we should update the github token doc page ) and krateo created the repository 🚀

But the Github workflow of the created repository is failing due to an error during pushing even if the github token has write:packages permission:

ERROR: failed to solve: failed to push ghcr.io/andregri/guest-fire-firefire:latest: unexpected status: 403 Forbidden
Error: buildx failed with: ERROR: failed to solve: failed to push ghcr.io/andregri/guest-fire-firefire:latest: unexpected status: 403 Forbidden
andregri commented 1 year ago

I solved the Github Action error by adding write permissions to the push job (fix commit here):

name: Build Docker image for every commit

on:
  push:
    branches: "**"

env:
  IMAGE_TAG: "latest"

jobs:
  push:
    name: Create docker image
    runs-on: ubuntu-latest
    permissions:
      packages: write
# omitted

The fireworks app is up now 🎆

Documentation and Pipelines tabs still in error...

braghettos commented 1 year ago

@andregri do you see a GitHub Workflow started in the new GitHub repository?

andregri commented 1 year ago

I see 3 workflows: the first 2 workflows launched by Krateo, the third workflow launched after my commit:

Screenshot 2023-03-28 at 14 17 50
braghettos commented 1 year ago

Pipelines tabs is configured within the values.yaml from Values tab:

  plugins:
    - endpointName: github
      icon: fa-solid fa-person-running
      name: pipelines
      type: pipeline
      values:
        - '[andregri][guest-fire-firefire2]Build Docker image for every commit'

Your repo is guest-fire-firefire, not guest-fire-firefire2. Could you post values for guest-fire-firefire2? Could you post logs of the pipeline-service pod?

andregri commented 1 year ago

Logs of pipeline-servicepod are:

$ kubectl logs pipeline-service-675665d775-cgrb8 -n krateo-system
2023-03-29T07:13:47.600Z info: /github/%5Bandregri%5D%5Bguest-fire-firefire2%5DBuild%20Docker%20image%20for%20every%20commit - GET - ::ffff:10.76.1.14
2023-03-29T07:13:47.899Z info: /github/%5Bandregri%5D%5Bguest-fire-firefire2%5DBuild%20Docker%20image%20for%20every%20commit - GET - ::ffff:10.76.1.14
2023-03-29T07:13:48.005Z error: /github/%5Bandregri%5D%5Bguest-fire-firefire2%5DBuild%20Docker%20image%20for%20every%20commit - Request failed with status code 404
2023-03-29T07:13:48.100Z error: /github/%5Bandregri%5D%5Bguest-fire-firefire2%5DBuild%20Docker%20image%20for%20every%20commit - Request failed with status code 404
2023-03-29T07:14:03.895Z info: /github/%5Bandregri%5D%5Bguest-fire-firefire2%5DBuild%20Docker%20image%20for%20every%20commit - GET - ::ffff:10.76.1.14
2023-03-29T07:14:03.901Z info: /github/%5Bandregri%5D%5Bguest-fire-firefire2%5DBuild%20Docker%20image%20for%20every%20commit - GET - ::ffff:10.76.1.14
2023-03-29T07:14:04.018Z error: /github/%5Bandregri%5D%5Bguest-fire-firefire2%5DBuild%20Docker%20image%20for%20every%20commit - Request failed with status code 404
2023-03-29T07:14:04.021Z error: /github/%5Bandregri%5D%5Bguest-fire-firefire2%5DBuild%20Docker%20image%20for%20every%20commit - Request failed with status code 404
andregri commented 1 year ago

We changed the log level of the deployment secret-service to debug and after clicking the Pipeline tab I got this log:

kubectl logs -f secret-service-79d89dbbd8-q5g6t -n krateo-system
2023-03-29T14:55:23.923Z info: /endpoint/github - GET - ::ffff:10.76.2.9
2023-03-29T14:55:24.225Z debug: {"statusCode":404,"body":"{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"secrets \\\"github-endpoint\\\" not found\"

Then we listed the secrets and we found out that the secret for GitHub endpoint was called github.com instead of github:

oc get secret -n krateo-system
NAME                                           TYPE                                  DATA   AGE
argocd-endpoint                                Opaque                                2      65m
argocd-initial-admin-secret                    Opaque                                1      66m
argocd-notifications-secret                    Opaque                                0      68m
argocd-secret                                  Opaque                                4      68m
github.com-endpoint                            Opaque                                2      57m

From the UI we removed the old GitHub endpoint and we created a new endpoint named github.

Now the Documentation and the Pipeline tabs are working.

Thank you for your help! 🎉

braghettos commented 1 year ago

@andregri we enhanced the possibility to define any kind of endpoint name: https://github.com/krateoplatformops/krateo-template-fireworksapp/commit/e7ab86e255d3d43fe64a8bd499d4fe78e7cf1e21. So there's no need anymore to choose a fixed name.