Portainer kubernetes API

Manage Kubernetes cluster

OpenAPI Specification

portainer-kubernetes-api-openapi.yml Raw ↑
swagger: '2.0'
info:
  contact:
    email: info@portainer.io
  description: 'Portainer API is an HTTP API served by Portainer. It is used by the Portainer UI and everything you can do with the UI can be done using the HTTP API.

    Examples are available at https://documentation.portainer.io/api/api-examples/

    You can find out more about Portainer at [http://portainer.io](http://portainer.io) and get some support on [Slack](http://portainer.io/slack/).


    # Authentication


    Most of the API environments(endpoints) require to be authenticated as well as some level of authorization to be used.

    Portainer API uses JSON Web Token to manage authentication and thus requires you to provide a token in the **Authorization** header of each request

    with the **Bearer** authentication mechanism.


    Example:


    ```

    Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidXNlcm5hbWUiOiJhZG1pbiIsInJvbGUiOjEsImV4cCI6MTQ5OTM3NjE1NH0.NJ6vE8FY1WG6jsRQzfMqeatJ4vh2TWAeeYfDhP71YEE

    ```


    # Security


    Each API environment(endpoint) has an associated access policy, it is documented in the description of each environment(endpoint).


    Different access policies are available:


    - Public access

    - Authenticated access

    - Restricted access

    - Administrator access


    ### Public access


    No authentication is required to access the environments(endpoints) with this access policy.


    ### Authenticated access


    Authentication is required to access the environments(endpoints) with this access policy.


    ### Restricted access


    Authentication is required to access the environments(endpoints) with this access policy.

    Extra-checks might be added to ensure access to the resource is granted. Returned data might also be filtered.


    ### Administrator access


    Authentication as well as an administrator role are required to access the environments(endpoints) with this access policy.


    # Execute Docker requests


    Portainer **DO NOT** expose specific environments(endpoints) to manage your Docker resources (create a container, remove a volume, etc...).


    Instead, it acts as a reverse-proxy to the Docker HTTP API. This means that you can execute Docker requests **via** the Portainer HTTP API.


    To do so, you can use the `/endpoints/{id}/docker` Portainer API environment(endpoint) (which is not documented below due to Swagger limitations). This environment(endpoint) has a restricted access policy so you still need to be authenticated to be able to query this environment(endpoint). Any query on this environment(endpoint) will be proxied to the Docker API of the associated environment(endpoint) (requests and responses objects are the same as documented in the Docker API).


    # Private Registry


    Using private registry, you will need to pass a based64 encoded JSON string ‘{"registryId":\<registryID value\>}’ inside the Request Header. The parameter name is "X-Registry-Auth".

    \<registryID value\> - The registry ID where the repository was created.


    Example:


    ```

    eyJyZWdpc3RyeUlkIjoxfQ==

    ```


    **NOTE**: You can find more information on how to query the Docker API in the [Docker official documentation](https://docs.docker.com/engine/api/v1.30/) as well as in [this Portainer example](https://documentation.portainer.io/api/api-examples/).

    '
  license:
    name: zlib
    url: https://github.com/portainer/portainer/blob/develop/LICENSE
  title: PortainerCE auth kubernetes API
  version: 2.39.1
basePath: /api
schemes:
- http
- https
tags:
- description: Manage Kubernetes cluster
  name: kubernetes
paths:
  /kubernetes/{id}/applications:
    get:
      description: 'Get a list of applications across all namespaces in the cluster. If the nodeName is provided, it will return the applications running on that node.

        **Access policy**: authenticated'
      operationId: GetAllKubernetesApplications
      parameters:
      - description: Environment(Endpoint) identifier
        in: path
        name: id
        required: true
        type: integer
      - description: Namespace name
        in: query
        name: namespace
        required: true
        type: string
      - description: Node name
        in: query
        name: nodeName
        required: true
        type: string
      produces:
      - application/json
      responses:
        '200':
          description: Success
          schema:
            items:
              $ref: '#/definitions/kubernetes.K8sApplication'
            type: array
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '404':
          description: Unable to find an environment with the specified identifier.
        '500':
          description: Server error occurred while attempting to retrieve the list of applications from the cluster.
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Get a list of applications across all namespaces in the cluster. If the nodeName is provided, it will return the applications running on that node.
      tags:
      - kubernetes
  /kubernetes/{id}/applications/count:
    get:
      description: 'Get the count of Applications across all namespaces in the cluster. If the nodeName is provided, it will return the count of applications running on that node.

        **Access policy**: Authenticated user.'
      operationId: GetAllKubernetesApplicationsCount
      parameters:
      - description: Environment identifier
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        '200':
          description: Success
          schema:
            type: integer
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '404':
          description: Unable to find an environment with the specified identifier.
        '500':
          description: Server error occurred while attempting to retrieve the count of all applications from the cluster.
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Get Applications count
      tags:
      - kubernetes
  /kubernetes/{id}/cluster_role_bindings/delete:
    post:
      consumes:
      - application/json
      description: 'Delete the provided list of cluster role bindings.

        **Access policy**: Authenticated user.'
      operationId: DeleteClusterRoleBindings
      parameters:
      - description: Environment identifier
        in: path
        name: id
        required: true
        type: integer
      - description: A list of cluster role bindings to delete
        in: body
        name: payload
        required: true
        schema:
          items:
            type: string
          type: array
      responses:
        '204':
          description: Success
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '404':
          description: Unable to find an environment with the specified identifier or unable to find a specific cluster role binding.
        '500':
          description: Server error occurred while attempting to delete cluster role bindings.
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Delete cluster role bindings
      tags:
      - kubernetes
  /kubernetes/{id}/cluster_roles/delete:
    post:
      consumes:
      - application/json
      description: 'Delete the provided list of cluster roles.

        **Access policy**: Authenticated user.'
      operationId: DeleteClusterRoles
      parameters:
      - description: Environment identifier
        in: path
        name: id
        required: true
        type: integer
      - description: A list of cluster roles to delete
        in: body
        name: payload
        required: true
        schema:
          items:
            type: string
          type: array
      responses:
        '204':
          description: Success
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '404':
          description: Unable to find an environment with the specified identifier or unable to find a specific cluster role.
        '500':
          description: Server error occurred while attempting to delete cluster roles.
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Delete cluster roles
      tags:
      - kubernetes
  /kubernetes/{id}/clusterrolebindings:
    get:
      description: 'Get a list of kubernetes cluster role bindings within the given environment at the cluster level.

        **Access policy**: Authenticated user.'
      operationId: GetAllKubernetesClusterRoleBindings
      parameters:
      - description: Environment identifier
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        '200':
          description: Success
          schema:
            items:
              $ref: '#/definitions/kubernetes.K8sClusterRoleBinding'
            type: array
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '404':
          description: Unable to find an environment with the specified identifier.
        '500':
          description: Server error occurred while attempting to retrieve the list of cluster role bindings.
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Get a list of kubernetes cluster role bindings
      tags:
      - kubernetes
  /kubernetes/{id}/clusterroles:
    get:
      description: 'Get a list of kubernetes cluster roles within the given environment at the cluster level.

        **Access policy**: Authenticated user.'
      operationId: GetAllKubernetesClusterRoles
      parameters:
      - description: Environment identifier
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        '200':
          description: Success
          schema:
            items:
              $ref: '#/definitions/kubernetes.K8sClusterRole'
            type: array
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '404':
          description: Unable to find an environment with the specified identifier.
        '500':
          description: Server error occurred while attempting to retrieve the list of cluster roles.
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Get a list of kubernetes cluster roles
      tags:
      - kubernetes
  /kubernetes/{id}/configmaps:
    get:
      description: 'Get a list of ConfigMaps across all namespaces in the cluster. For non-admin users, it will only return ConfigMaps based on the namespaces that they have access to.

        **Access policy**: Authenticated user.'
      operationId: GetAllKubernetesConfigMaps
      parameters:
      - description: Environment identifier
        in: path
        name: id
        required: true
        type: integer
      - description: Set to true to include information about applications that use the ConfigMaps in the response
        in: query
        name: isUsed
        required: true
        type: boolean
      produces:
      - application/json
      responses:
        '200':
          description: Success
          schema:
            items:
              $ref: '#/definitions/kubernetes.K8sConfigMap'
            type: array
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '404':
          description: Unable to find an environment with the specified identifier.
        '500':
          description: Server error occurred while attempting to retrieve all configmaps from the cluster.
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Get a list of ConfigMaps
      tags:
      - kubernetes
  /kubernetes/{id}/configmaps/count:
    get:
      description: 'Get the count of ConfigMaps across all namespaces in the cluster. For non-admin users, it will only return the count of ConfigMaps based on the namespaces that they have access to.

        **Access policy**: Authenticated user.'
      operationId: GetAllKubernetesConfigMapsCount
      parameters:
      - description: Environment identifier
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        '200':
          description: Success
          schema:
            type: integer
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '404':
          description: Unable to find an environment with the specified identifier.
        '500':
          description: Server error occurred while attempting to retrieve the count of all configmaps from the cluster.
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Get ConfigMaps count
      tags:
      - kubernetes
  /kubernetes/{id}/cron_jobs:
    get:
      description: 'Get a list of kubernetes Cron Jobs that the user has access to.

        **Access policy**: Authenticated user.'
      operationId: GetKubernetesCronJobs
      parameters:
      - description: Environment identifier
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        '200':
          description: Success
          schema:
            items:
              $ref: '#/definitions/kubernetes.K8sCronJob'
            type: array
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '404':
          description: Unable to find an environment with the specified identifier.
        '500':
          description: Server error occurred while attempting to retrieve the list of Cron Jobs.
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Get a list of kubernetes Cron Jobs
      tags:
      - kubernetes
  /kubernetes/{id}/cron_jobs/delete:
    post:
      consumes:
      - application/json
      description: 'Delete the provided list of Cron Jobs.

        **Access policy**: Authenticated user.'
      operationId: DeleteCronJobs
      parameters:
      - description: Environment identifier
        in: path
        name: id
        required: true
        type: integer
      - description: A map where the key is the namespace and the value is an array of Cron Jobs to delete
        in: body
        name: payload
        required: true
        schema:
          $ref: '#/definitions/kubernetes.K8sCronJobDeleteRequests'
      responses:
        '204':
          description: Success
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '404':
          description: Unable to find an environment with the specified identifier or unable to find a specific service account.
        '500':
          description: Server error occurred while attempting to delete Cron Jobs.
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Delete Cron Jobs
      tags:
      - kubernetes
  /kubernetes/{id}/dashboard:
    get:
      consumes:
      - application/json
      description: 'Get the dashboard summary data which is simply a count of a range of different commonly used kubernetes resources.

        **Access policy**: Authenticated user.'
      operationId: GetKubernetesDashboard
      parameters:
      - description: Environment (Endpoint) identifier
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        '200':
          description: Success
          schema:
            items:
              $ref: '#/definitions/kubernetes.K8sDashboard'
            type: array
        '400':
          description: Invalid request
        '500':
          description: Server error
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Get the dashboard summary data
      tags:
      - kubernetes
  /kubernetes/{id}/describe:
    get:
      description: 'Get a description of a kubernetes resource.

        **Access policy**: Authenticated user.'
      operationId: DescribeResource
      parameters:
      - description: Environment identifier
        in: path
        name: id
        required: true
        type: integer
      - description: Resource name
        in: query
        name: name
        required: true
        type: string
      - description: Resource kind
        in: query
        name: kind
        required: true
        type: string
      - description: Namespace
        in: query
        name: namespace
        type: string
      produces:
      - application/json
      responses:
        '200':
          description: Success
          schema:
            $ref: '#/definitions/kubernetes.describeResourceResponse'
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '404':
          description: Unable to find an environment with the specified identifier.
        '500':
          description: Server error occurred while attempting to retrieve resource description
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Get a description of a kubernetes resource
      tags:
      - kubernetes
  /kubernetes/{id}/events:
    get:
      description: 'Get events by query param resourceId

        **Access policy**: Authenticated user.'
      operationId: getAllKubernetesEvents
      parameters:
      - description: Environment identifier
        in: path
        name: id
        required: true
        type: integer
      - description: The resource id of the involved kubernetes object
        in: query
        name: resourceId
        type: string
      produces:
      - application/json
      responses:
        '200':
          description: Success
          schema:
            items:
              $ref: '#/definitions/kubernetes.K8sEvent'
            type: array
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '500':
          description: Server error occurred while attempting to retrieve the events.
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Gets kubernetes events
      tags:
      - kubernetes
  /kubernetes/{id}/ingresscontrollers:
    get:
      description: 'Get a list of ingress controllers for the given environment. If the allowedOnly query parameter is set, only ingress controllers that are allowed by the environment''s ingress configuration will be returned.

        **Access policy**: Authenticated user.'
      operationId: GetAllKubernetesIngressControllers
      parameters:
      - description: Environment identifier
        in: path
        name: id
        required: true
        type: integer
      - description: Only return allowed ingress controllers
        in: query
        name: allowedOnly
        type: boolean
      produces:
      - application/json
      responses:
        '200':
          description: Success
          schema:
            items:
              $ref: '#/definitions/kubernetes.K8sIngressController'
            type: array
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '404':
          description: Unable to find an environment with the specified identifier.
        '500':
          description: Server error occurred while attempting to retrieve ingress controllers
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Get a list of ingress controllers
      tags:
      - kubernetes
    put:
      consumes:
      - application/json
      description: 'Update (block/unblock) ingress controllers for the provided environment.

        **Access policy**: Authenticated user.'
      operationId: UpdateKubernetesIngressControllers
      parameters:
      - description: Environment identifier
        in: path
        name: id
        required: true
        type: integer
      - description: Ingress controllers
        in: body
        name: body
        required: true
        schema:
          items:
            $ref: '#/definitions/kubernetes.K8sIngressController'
          type: array
      produces:
      - application/json
      responses:
        '204':
          description: Success
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '404':
          description: Unable to find an environment with the specified identifier or unable to find the ingress controllers to update.
        '500':
          description: Server error occurred while attempting to update ingress controllers.
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Update (block/unblock) ingress controllers
      tags:
      - kubernetes
  /kubernetes/{id}/ingresses:
    get:
      description: 'Get kubernetes ingresses at the cluster level for the provided environment.

        **Access policy**: Authenticated user.'
      operationId: GetAllKubernetesClusterIngresses
      parameters:
      - description: Environment identifier
        in: path
        name: id
        required: true
        type: integer
      - description: Lookup services associated with each ingress
        in: query
        name: withServices
        type: boolean
      produces:
      - application/json
      responses:
        '200':
          description: Success
          schema:
            items:
              $ref: '#/definitions/kubernetes.K8sIngressInfo'
            type: array
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '404':
          description: Unable to find an environment with the specified identifier.
        '500':
          description: Server error occurred while attempting to retrieve ingresses.
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Get kubernetes ingresses at the cluster level
      tags:
      - kubernetes
  /kubernetes/{id}/ingresses/count:
    get:
      description: 'Get the number of kubernetes ingresses within the given environment.

        **Access policy**: Authenticated user.'
      operationId: GetAllKubernetesClusterIngressesCount
      parameters:
      - description: Environment identifier
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        '200':
          description: Success
          schema:
            type: integer
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '404':
          description: Unable to find an environment with the specified identifier.
        '500':
          description: Server error occurred while attempting to retrieve ingresses count.
      security:
      - ApiKeyAuth: []
        jwt: []
      summary: Get Ingresses count
      tags:
      - kubernetes
  /kubernetes/{id}/ingresses/delete:
    post:
      consumes:
      - application/json
      description: 'Delete one or more Ingresses in the provided environment.

        **Access policy**: Authenticated user.'
      operationId: DeleteKubernetesIngresses
      parameters:
      - description: Environment identifier
        in: path
        name: id
        required: true
        type: integer
      - description: Ingress details
        in: body
        name: body
        required: true
        schema:
          $ref: '#/definitions/kubernetes.K8sIngressDeleteRequests'
      produces:
      - application/json
      responses:
        '204':
          description: Success
        '400':
          description: Invalid request payload, such as missing required fields or fields not meeting validation criteria.
        '401':
          description: Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
        '403':
          description: Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
        '404':
          description: Unable to find an environment with the spe

# --- truncated at 32 KB (212 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/portainer/refs/heads/main/openapi/portainer-kubernetes-api-openapi.yml