Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2321: Add new objects to OpenShift model (with operators.coreos.com and monitoring.coreos.com APIs) #2412

Merged
merged 1 commit into from Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Expand Up @@ -10,6 +10,8 @@
* Fix #2306: Make KubernetesServer CRUD mode work with informers
* Fix #2418: CertificateSigningRequest doesn't implement Namespaced
* Fix #2265: InAnyNamespace uses invalid api endpoint for SelfSubjectAccessReviews
* Fix #2404: Readiness.isReady doesn't handle extensions/v1beta1 Deployment
* Fix #2389: KubernetesServer JUnit rule ignores value of https when using crud mode

#### Improvements
* Fix #2331: Fixed documentation for namespaced informer for all custom types implementing `Namespaced` interface
Expand All @@ -21,18 +23,21 @@
* Fix #2353: chore: bump workflow action-setup versions + kubernetes to 1.18.6
* Fix #2292: Update createOrReplace to do replace when create fails with conflict
* Fix: Bump SnakeYaml to version 1.26 (as required for OSGi bundle for jackson-dataformat-yaml)
* Fix #2401: bump maven-resources-plugin from 3.1.0 to 3.2.0
* Fix #2405: bump mockito-core from 3.4.4 to 3.5.0

#### New Features
* CSI Volume Snapshot extension
* Fix #2311: Add Support for creating bootstrap project template
* Fix #2287: Add support for V1 and V1Beta1 CustomResourceDefinition
* Fix #2319: Create Config without using auto-configure functionality or setting env variables
* Fix #2284: Supports create and run a particular image in a pod operation using client
* Fix #2321: Add Support for new resources in OpenShift Model

_**Note**_: Some classes have been moved to other packages:
- CustomResourceDefinition has been moved to `io.fabric8.kubernetes.api.model.apiextensions.v1` and `io.fabric8.kubernetes.api.model.apiextensions.v1beta1`
- SubjectAccessReview, SelfSubjectAccessReview, LocalSubjectAccessReview and SelfSubjectRulesReview have been moved to `io.fabric8.kubernetes.api.model.authorization.v1` and `io.fabric8.kubernetes.api.model.authorization.v1beta1`

- `io.fabric8.tekton.pipeline.v1beta1.WorkspacePipelineDeclaration` is now `io.fabric8.tekton.pipeline.v1beta1.PipelineWorkspaceDeclaration`
### 4.10.3 (2020-07-14)
#### Bugs
* Fix #2285: Raw CustomResource API createOrReplace does not propagate exceptions from create
Expand Down
217 changes: 217 additions & 0 deletions doc/CHEATSHEET.md
Expand Up @@ -49,6 +49,12 @@ This document contains common usages of different resources using Fabric8 Kubern
* [Route](#route)
* [Project](#project)
* [ImageStream](#imagestream)
* [CatalogSource](#catalogsource)
* [PrometheusRule](#prometheusrule)
* [ServiceMonitor](#servicemonitor)
* [CluserResourceQuota](#clusterresourcequota)
* [ClusterVersion](#clusterversion)
* [EgressNetworkPolicy](#egressnetworkpolicy)

* [Tekton Client](#tekton-client)
* [Initializing Tekton Client](#initializing-tekton-client)
Expand Down Expand Up @@ -2617,6 +2623,217 @@ ImageStreamList isList = client.imageStreams().inNamespace("default").withLabel(
```
Boolean bDeleted = client.imageStreams().inNamespace("default").withName("example-camel-cdi").delete();
```
#### CatalogSource
`CatalogSource` is available for usage in OpenShift Client via `client.operatorHub().catalogSources()`. Here are some common examples of it's usage:
- Load `CatalogSource` from YAML:
```
CatalogSource cs = client.operatorHub().catalogSources()
.load(new FileInputStream("/test-catalogsource.yml").get();
```
- Create `CatalogSource`:
```
CatalogSource cs = new CatalogSourceBuilder()
.withNewMetadata().withName("foo").endMetadata()
.withNewSpec()
.withSourceType("Foo")
.withImage("nginx:latest")
.withDisplayName("Foo Bar")
.withPublisher("Fabric8")
.endSpec()
.build();
client.operatorHub().catalogSources().inNamespace("default").createOrReplace(cs);
```
- List `CatalogSource` in some namespace:
```
CatalogSourceList csList = client.operatorHub().catalogSources().inNamespace("ns1").list();
```
- List `CatalogSource` in any namespace:
```
CatalogSourceList csList = client.operatorHub().catalogSources().inAnyNamespace().list();
```
- List `CatalogSource` in some namespace with some labels:
```
CatalogSourceList csList = client.operatorHub().catalogSources().inNamespace("default").withLabel("foo", "bar").list();
```
- Delete `CatalogSource`:
```
client.operatorHub().catalogSources().inNamespace("default").withName("foo").delete();
```

#### PrometheusRule
`PrometheusRule` is available for usage in OpenShift Client via `client.monitoring().prometheusRules()`. Here are some common examples of it's usage:
- Load `PrometheusRule` from YAML:
```
PrometheusRule prometheusRule = client.monitoring().prometheusRules()
.load(new FileInputStream("/test-prometheusrule.yml").get();
```
- Create `PrometheusRule`:
```
PrometheusRule prometheusRule = new PrometheusRuleBuilder()
.withNewMetadata().withName("foo").endMetadata()
.withNewSpec()
.addNewGroup()
.withName("./example-rules")
.addNewRule()
.withAlert("ExampleAlert")
.withNewExpr().withStrVal("vector(1)").endExpr()
.endRule()
.endGroup()
.endSpec()
.build();
client.monitoring().prometheusRules().inNamespace("default").createOrReplace(prometheusRule);
```
- List `PrometheusRule` in some namespace:
```
PrometheusRuleList prList = client.monitoring().prometheusRules().inNamespace("ns1").list();
```
- List `PrometheusRule` in any namespace:
```
PrometheusRuleList prList = client.monitoring().prometheusRules().inAnyNamespace().list();
```
- List `PrometheusRule` in some namespace with some labels:
```
PrometheusRuleList prList = client.monitoring().prometheusRules().inNamespace("default").withLabel("foo", "bar").list();
```
- Delete `PrometheusRule`:
```
client.monitoring().prometheusRules().inNamespace("default").withName("foo").delete();
```

#### ServiceMonitor
`ServiceMonitor` is available for usage in OpenShift Client via `client.monitoring().serviceMonitors()`. Here are some common examples of it's usage:
- Load `ServiceMonitor` from YAML:
```
ServiceMonitor serviceMonitor = client.monitoring().serviceMonitors()
.load(new FileInputStream("/test-servicemonitor.yml").get();
```
- Create `ServiceMonitor`:
```
ServiceMonitor serviceMonitor = new ServiceMonitorBuilder()
.withNewMetadata()
.withName("foo")
.addToLabels("prometheus", "frontend")
.endMetadata()
.withNewSpec()
.withNewNamespaceSelector().withAny(true).endNamespaceSelector()
.withNewSelector()
.addToMatchLabels("prometheus", "frontend")
.endSelector()
.addNewEndpoint()
.withPort("http-metric")
.withInterval("15s")
.endEndpoint()
.endSpec()
.build();

client.monitoring().serviceMonitors().inNamespace("rokumar").createOrReplace(serviceMonitor)
```
- List `ServiceMonitor` in some namespace:
```
ServiceMonitorList serviceMonitorList = client.monitoring().serviceMonitors().inNamespace("ns1").list();
```
- List `ServiceMonitor` in any namespace:
```
ServiceMonitorList serviceMonitorList = client.monitoring().serviceMonitors().inAnyNamespace().list();
```
- List `ServiceMonitor` in some namespace with some labels:
```
ServiceMonitorList serviceMonitorList = client.monitoring().catalogSources().inNamespace("default").withLabel("foo", "bar").list();
```
- Delete `ServiceMonitor`:
```
client.operatorHub().monitoring().inNamespace("default").withName("foo").delete();
```

#### ClusterResourceQuota
- Create `ClusterResourceQuota`:
```
try (OpenShiftClient client = new DefaultOpenShiftClient()) {
Map<String, Quantity> hard = new HashMap<>();
hard.put("pods", new Quantity("10"));
hard.put("secrets", new Quantity("20"));
ClusterResourceQuota acrq = new ClusterResourceQuotaBuilder()
.withNewMetadata().withName("foo").endMetadata()
.withNewSpec()
.withNewSelector()
.addToAnnotations("openshift.io/requester", "foo-user")
.endSelector()
.withQuota(new ResourceQuotaSpecBuilder()
.withHard(hard)
.build())
.endSpec()
.build();

client.quotas().clusterResourceQuotas().createOrReplace(acrq);
}
```
- List `ClusterResourceQuota` from server:
```
ClusterResourceQuotaList clusterResourceQuotaList = client.quotas().clusterResourceQuotas().list();
```
- Delete `ClusterResourceQuota`:
```
client.quotas().clusterResourceQuotas().withName("foo").delete();
```

#### ClusterVersion
- Fetch Cluster Version:
```
try (OpenShiftClient client = new DefaultOpenShiftClient()) {
ClusterVersion clusterVersion = client.config().clusterVersions().withName("version").get();
System.out.println("Cluster Version: " + clusterVersion.getStatus().getDesired().getVersion());
}
```

### EgressNetworkPolicy
`EgressNetworkPolicy` is available for usage in OpenShift Client via `client..egressNetworkPolicys()`. Here are some common examples of it's usage:
- Load `EgressNetworkPolicy` from YAML:
```
EgressNetworkPolicy egressNetworkPolicy = client.egressNetworkPolicies()
.load(new FileInputStream("/test-enp.yml").get();
```
- Create `EgressNetworkPolicy`:
```
try (OpenShiftClient client = new DefaultOpenShiftClient()) {
EgressNetworkPolicy enp = new EgressNetworkPolicyBuilder()
.withNewMetadata()
.withName("foo")
.withNamespace("default")
.endMetadata()
.withNewSpec()
.addNewEgress()
.withType("Allow")
.withNewTo()
.withCidrSelector("1.2.3.0/24")
.endTo()
.endEgress()
.addNewEgress()
.withType("Allow")
.withNewTo()
.withDnsName("www.foo.com")
.endTo()
.endEgress()
.endSpec()
.build();
client.egressNetworkPolicies().inNamespace("default").createOrReplace(enp);
}
```
- List `EgressNetworkPolicy` in some namespace:
```
EgressNetworkPolicyList egressNetworkPolicyList = client.egressNetworkPolicies().inNamespace("default").list();
```
- List `EgressNetworkPolicy` in any namespace:
```
EgressNetworkPolicyList egressNetworkPolicyList = client.egressNetworkPolicies().inAnyNamespace().list();
```
- List `EgressNetworkPolicy` in some namespace with some labels:
```
EgressNetworkPolicyList egressNetworkPolicyList = client.egressNetworkPolicies().inNamespace("default").withLabel("foo", "bar").list();
```
- Delete `EgressNetworkPolicy`:
```
client.egressNetworkPolicies().inNamespace("default").withName("foo").delete();
```

### Tekton Client
Fabric8 Kubernetes Client also has an extension for Tekton.
Expand Down
12 changes: 7 additions & 5 deletions kubernetes-model-generator/go.mod
Expand Up @@ -3,11 +3,13 @@ module github.com/fabric8io/kubernetes-client/kubernetes-model-generator
go 1.14

require (
github.com/openshift/api v0.0.0-20200413201024-c6e8c9b6eb9a
k8s.io/api v0.18.0
k8s.io/apiextensions-apiserver v0.18.0
k8s.io/apimachinery v0.18.0
k8s.io/client-go v0.18.0
github.com/coreos/prometheus-operator v0.41.1 // indirect
github.com/openshift/api v0.0.0-20200803131051-87466835fcc0
github.com/operator-framework/api v0.3.12
k8s.io/api v0.19.0-rc.2
k8s.io/apiextensions-apiserver v0.18.2
k8s.io/apimachinery v0.19.0-rc.2
k8s.io/client-go v0.18.3
k8s.io/kubernetes v1.18.0
k8s.io/metrics v0.18.0
)
Expand Down