Questo contenuto non è disponibile nella lingua selezionata.

Chapter 2. Installing API controller


To install API controller use the community Operator.

Prerequisites

  • cluster-admin access to an OpenShift cluster.

Procedure

  1. In the OpenShift Container Platform web console, log in with cluster-admin privileges.
  2. In the left navigation menu, click Operators > OperatorHub.
  3. In the Filter by keyword text box, enter Apicurio to find the Apicurio API Controller.
  4. Read the information about the Operator, and click Install to display the Operator subscription page.
  5. Accept the default subscription settings noting the following:

    • Installation mode: All namespaces on the cluster (default).
    • Installed namespace: Select the namespace where you want to install the Operator, for example, api-controller. If the namespace does not already exist, click this field and select Create Project to create the namespace.
    • Approval Strategy: Select Automatic or Manual.
  6. Click Install, and wait a few moments until the Operator is installed and ready for use.
  7. Verify that the Operator is installed. After you have installed the Operator, click Operators > Installed Operators to verify that the Apicurio API Controller is installed in your selected namespace, for example api-controller.
  8. Change to the Developer view in the OpenShift Container Platform web console to apply the YAML required for installation.
  9. Create a PostgreSQL database using the following YAML in the api-controller namespace:

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: registry-pvc
      namespace: api-controller
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 1Gi  # Adjust the storage size as needed
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      namespace: "api-controller"
      labels:
        app: postgresql
      name: postgresql
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: postgresql
      template:
        metadata:
          labels:
            app: postgresql
        spec:
          initContainers:
            - name: init-data
              image: busybox
              command: ['sh', '-c', 'rm -rf /var/lib/postgresql/data/* && mkdir -p /var/lib/postgresql/data/pgdata']
              volumeMounts:
                - mountPath: "/var/lib/postgresql/data"
                  name: "registry-pgdata"
          containers:
            - name: postgresql
              image: quay.io/debezium/postgres:13-alpine
              ports:
                - containerPort: 5432
              env:
                - name: POSTGRES_DB
                  value: registry
                - name: POSTGRES_USER
                  value: apicurio
                - name: POSTGRES_PASSWORD
                  value: registry
                - name: PGDATA
                  value: "/var/lib/postgresql/data/pgdata"
              volumeMounts:
                - mountPath: "/var/lib/postgresql/data"
                  name: "registry-pgdata"
          volumes:
            - name: registry-pgdata
              persistentVolumeClaim:
                claimName: registry-pvc
    ---
    apiVersion: v1
    kind: Service
    metadata:
      namespace: "api-controller"
      labels:
        app: postgresql
      name: postgresql-service
    spec:
      ports:
        - name: http
          port: 5432
          protocol: TCP
          targetPort: 5432
      selector:
        app: postgresql
      type: ClusterIP
  10. Create a CR named apicurio, and the required Routes using the following YAML in the api-controller namespace:

    Note

    Replace mycluster.example.com with your cluster hostname.

    # Replace mycluster.example.com with your cluster hostname
    # Create an API Controller custom resource
    apiVersion: registry.apicur.io/v1
    kind: ApicurioRegistry3
    metadata:
      name: apicurio
      namespace: api-controller
    spec:
      studioUi:
        enabled: true
        env:
          - name: APICURIO_REGISTRY_API_URL
            value: 'https://api-controller-app.apps.mycluster.example.com/apis/registry/v3'
          - name: APICURIO_REGISTRY_UI_URL
            value: 'https://api-controller-ui.apps.mycluster.example.com'
      ui:
        env:
          - name: REGISTRY_API_URL
            value: 'https://api-controller-app.apps.mycluster.example.com/apis/registry/v3'
      app:
        sql:
          dataSource:
            username: apicurio
            password: registry
            url: 'jdbc:postgresql://postgresql-service:5432/registry'
    ---
    # Create a route for the Apicurio Registry API
    apiVersion: route.openshift.io/v1
    kind: Route
    metadata:
      name: api-controller-registry-api
      namespace: api-controller
    spec:
      host: api-controller-app.apps.mycluster.example.com
      path: /
      to:
        kind: Service
        name: apicurio-app-service
      port:
        targetPort: http
      tls:
        termination: edge
        insecureEdgeTerminationPolicy: Redirect
      wildcardPolicy: None
    ---
    # Create a route for the Apicurio Registry UI
    apiVersion: route.openshift.io/v1
    kind: Route
    metadata:
      name: api-controller-registry-ui
      namespace: api-controller
    spec:
      host: api-controller-ui.apps.mycluster.example.com
      path: /
      to:
        kind: Service
        name: apicurio-ui-service
      port:
        targetPort: http
      tls:
        termination: edge
        insecureEdgeTerminationPolicy: Redirect
      wildcardPolicy: None
    ---
    # Create a route for the Apicurio Studio UI
    apiVersion: route.openshift.io/v1
    kind: Route
    metadata:
      name: api-controller-studio-ui
      namespace: api-controller
    spec:
      host: api-controller-studio-ui.apps.mycluster.example.com
      path: /
      to:
        kind: Service
        name: apicurio-studio-ui-service
      port:
        targetPort: http
      tls:
        termination: edge
        insecureEdgeTerminationPolicy: Redirect
      wildcardPolicy: None

Verification

Navigate to the api-controller-studio-ui Route and click the Location URL. The Apicurio Studio console should be displayed.

Red Hat logoGithubRedditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita ilBlog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

© 2024 Red Hat, Inc.