tree: 625d961d5d45b616ef7daa3c13a3fda65354d074 [path history] [tgz]
  1. cmd/
  2. config/
  3. docs/
  4. e2e/
  5. hack/
  6. pkg/
  7. .gitignore
  8. code-of-conduct.md
  9. CONTRIBUTING.md
  10. Dockerfile
  11. Gopkg.lock
  12. Gopkg.toml
  13. LICENSE
  14. Makefile
  15. OWNERS
  16. OWNERS_ALIASES
  17. PROJECT
  18. README.md
  19. SECURITY_CONTACTS
vendor/github.com/kubernetes-sigs/application/README.md

Kubernetes Applications

Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.

The above description, from the Kubernetes homepage, is centered on containerized applications. Yet, the Kubernetes metadata, objects, and visualizations (e.g., within Dashboard) are focused on container infrastructure rather than the applications themselves.

The Application CRD (Custom Resource Definition) and Controller in this project aim to change that in a way that's interoperable between many supporting tools.

It provides:

  • The ability to describe an applications metadata (e.g., that an application like WordPress is running)
  • A point to connect the infrastructure, such as Deployments, to as a root object. This is useful for tying things together and even cleanup (i.e., garbage collection)
  • Information for supporting applications to help them query and understand the objects supporting an application
  • Application level health checks

This can be used by:

  • Application operators who want to center what they operate on applications
  • Tools, such as Helm, that center their package releases on application installations can do so in a way that's interoperable with other tools (e.g., Dashboard)
  • Dashboards that want to visualize the applications in addition to or instead of an infrastructure view

Goals

  1. Provide a standard API for creating, viewing, and managing applications in Kubernetes.
  2. Provide a CLI implementation, via kubectl, that interacts with the Application API.
  3. Provide installation status and garbage collection for applications.
  4. Provide a standard way for applications to surface a basic health check to the UIs.
  5. Provide an explicit mechanism for applications to declare dependencies on another application.
  6. Promote interoperability among ecosystem tools and UIs by creating a standard that tools MAY implement.
  7. Promote the use of common labels and annotations for Kubernetes Applications.

Non-Goals

  1. Create a standard that all tools MUST implement.
  2. Provide a way for UIs to surface metrics from an application.

Application Objects

After creating the Application CRD, you can create Application objects. An Application object provides a way for you to aggregate individual Kubernetes components (e.g. Services, Deployments, StatefulSets, Ingresses, CRDs), and manage them as a group. It provides UIs with a resource that allows for the aggregation and display of all the components in the Application.

Building

This project uses the kubebuilder tool for code generation. kubebuilder provides the same code generation features (and a bit more) for Custom Resource Definitions and Extension API Servers that are provided by the Kubernetes project. Installing kubebuilder is not needed to build the project, but it is needed to do things like adding additional resources.

To generate the manifests and run unit tests:

make

Controller

The controller doesn‘t do much at the moment. However, if you’d like to build an image you'll need to install Docker and golang 1.9 or greater. To build the controller into an image named image use the following command.

make docker-build IMG=<image>
make docker-push IMG=<image>

Installing the CRD

To install the crd and the controller, just run:

make deploy

This will install the controller into the application-system namespace and with the default RBAC permissions.

There is also a sample Application CR in the config/samples folder.

Using the Application CRD

The application CRD can be used both via manifests and programmatically.

Manifests

The docs directory contains a manifest that shows how to you can integrate the Application CRD with a WordPress deployment.

The Application object shown below declares that the Application is a WordPress installation that uses StatefulSets and Services. It also contains some other relevant metadata described above.

apiVersion: app.k8s.io/v1beta1
kind: Application
metadata:
  name: "wordpress-01"
  labels:
    app.kubernetes.io/name: "wordpress-01"
    app.kubernetes.io/version: "3"
spec:
  selector:
    matchLabels:
     app.kubernetes.io/name: "wordpress-01"
  componentKinds:
    - group: core
      kind: Service
    - group: apps
      kind: Deployment
    - group: apps
      kind: StatefulSet
  assemblyPhase: "Pending"
  descriptor:
    version: "4.9.4"
    description: "WordPress is open source software you can use to create a beautiful website, blog, or app."
    icons:
      - src: "https://example.com/wordpress.png"
        type: "image/png"
    type: "wordpress"
    maintainers:
      - name: Kenneth Owens
        email: kow3ns@github.com
    owners:
      - "Kenneth Owens kow3ns@github.com"
    keywords:
      - "cms"
      - "blog"
      - "wordpress"
    links:
      - description: About
        url: "https://wordpress.org/"
      - description: Web Server Dashboard
        url: "https://metrics/internal/wordpress-01/web-app"
      - description: Mysql Dashboard
        url: "https://metrics/internal/wordpress-01/mysql"

Notice that each Service and StatefulSet is labeled such that Application's Selector matches the labels.

app.kubernetes.io/name: "wordpress-01"

The additional labels on the Applications components come from the recommended application labels and annotations.

You can use the standard kubectl verbs (e.g. get, apply, create, delete, list, watch) to interact with an Application specified in a manifest.

Programmatically

Kubebuilder provides a client to get, create, update and delete resources and this also works for application resources. This is well documented in the kubebuilder book: https://book.kubebuilder.io/

Create a client:

kubeClient, err := client.New(config)

Get an application resource:

object := &applicationsv1beta1.Application{}
objectKey := types.NamespacedName{
    Namespace: "namespace",
    Name: "name",
}
err = kubeClient.Get(context.TODO(), objectKey, object)

Create a new application resource:

app := &applicationsv1beta1.Application{
	...
}
err = kubeClient.Create(context.TODO(), app)

Contributing

Go to the CONTRIBUTING.md documentation

Community, discussion, contribution, and support

Learn how to engage with the Kubernetes community on the community page.

You can reach the maintainers of this project at:

Code of conduct

Participation in the Kubernetes community is governed by the Kubernetes Code of Conduct.