Snowdrop :: Application CRD:: Client

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

me.snowdrop
ArtifactId

ArtifactId

application-crd-client
Last Version

Last Version

1.1.1
Release Date

Release Date

Type

Type

bundle
Description

Description

Snowdrop :: Application CRD:: Client
Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Project Organization

Project Organization

Red Hat

Download application-crd-client

Dependencies

compile (5)

Group / Artifact Type Version
io.sundr : builder-annotations jar 0.18.0
me.snowdrop : application-crd-model jar 1.1.1
io.fabric8 : kubernetes-client jar 4.2.2
com.fasterxml.jackson.module : jackson-module-jaxb-annotations jar 2.6.3
javax.validation : validation-api jar 1.1.0.Final

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.16.4

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Application CRD Client


Features

  • Java DSL that provides access to Application CRD resources
  • Works on top of the fabric8 kubernetes-client

Usage

Throughout the usage section code samples will be provided. The code samples are going to use the following naming conventions:

  • ac The Application CRD client instance
  • kc The Fabric8 Kubernetes client instance

Configuring the client

There are two ways of creating an instance of the service catalog client.

  • adapting from an existing instance of KubernetesClient
  • manual configuration and instantiation

Adapting

When the Application CRD API is provided by the same API server as the Kubernetes API (both APIs are proxied together), you can easily adapt an existing KubernetesClient instance.

KubernetesClient kc = new DefaultKubernetesClient();
Application ac = kc.adapt(ApplicationClient.class);

This approach is pretty easy, but it can only work if the topology requirements explained above are satisfied. If not, the client needs to be configured manually.

Manual Configuration

To manually instantiate the client, you just need to create a configuration object, that specifies at least the url of the api server and a way to authenticate to it. These may be specified:

  • explicitly
    • via the io.fabric8io.kubernetes.client.Config DSL
  • implicitly
    • using system properties
    • using env variables
    • using ~/.kube/confg
Using the Config DSL
  import io.fabric8.kubernetes.client.Config;
  import io.fabric8.kubernetes.client.ConfigBuilder;
  
  ...
  
  Config config = new ConfigBuilder().withMasterUrl("https://url.to.api.server")
      .withOautToken("sometoken")
      .build();
      
  ApplicationClient app = new DefaultApplicationClient(config);

Manipulating Resources

Application

In order to create an Application:

    Application app = ac.applications().createNew()
            .withNewMetadata()
                .withName("wordpress-01")
                .addToLabels("app/kubernetes.io/name", "wordpress-01")
                .addToLabels("app/kubernetes.io/version", "3")
            .endMetadata()
            .withNewSpec()
            .withNewSelector()
                .addToMatchLabels("app.kubernetes.io/name", "wordpress-01")
            .endSelector()
            .addNewComponentKind("core" ,"Service")
            .addNewComponentKind("apps" ,"Deployment")
            .addNewComponentKind("apps" ,"StatefulSet")
            .withAssemblyPhase("Pending")
            .withNewDescriptor()
            .withVersion("4.9.4")
            .withDescription("WordPress is open source software you can use to create a beautiful website, blog, or app.")
            .addNewIcon()
                .withSrc("https://example.com/wordpress.png")
                .withType("image/png")
            .endIcon()
            .addNewMaintainer()
                .withName("Kenneth Owens")
                .withEmail("[email protected]")
            .endMaintainer()
            .addNewLink("About", "https://wordpress.org/")
            .endDescriptor()
            .endSpec()
            .done();
me.snowdrop

Snowdrop

Home of Snowdrop

Versions

Version
1.1.1
1.1.0
1.0.9
1.0.8
1.0.7
1.0.6
1.0.5
1.0.4