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

Operator 0.5.3 #215

Merged
merged 3 commits into from
Jan 25, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions deploy/crds/quickstart-resources-cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: wildfly.org/v1alpha1
kind: WildFlyServer
metadata:
name: quickstart
spec:
applicationImage: "quay.io/wildfly-quickstarts/wildfly-operator-quickstart:18.0"
replicas: 2
resources:
limits:
cpu: "1"
memory: "512Mi"
requests:
cpu: "500m"
memory: "256Mi"
32 changes: 32 additions & 0 deletions deploy/crds/wildfly.org_wildflyservers_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,33 @@ spec:
format: int32
minimum: 0
type: integer
resources:
description: 'ResourcesSpec defines the resources used by the WildFlyServer,
ie CPU and memory, use limits and requests. More info: https://pkg.go.dev/k8s.io/[email protected]/core/v1#ResourceRequirements'
properties:
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount of compute resources
allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Requests describes the minimum amount of compute
resources required. If Requests is omitted for a container,
it defaults to Limits if that is explicitly specified, otherwise
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
secrets:
description: Secrets is a list of Secrets in the same namespace as
the WildFlyServer object, which shall be mounted into the WildFlyServer
Expand Down Expand Up @@ -534,15 +561,20 @@ spec:
\n Read-only."
format: int32
type: integer
selector:
description: selector for pods, used by HorizontalPodAutoscaler
type: string
required:
- replicas
- scalingdownPods
- selector
type: object
type: object
served: true
storage: true
subresources:
scale:
labelSelectorPath: .status.selector
specReplicasPath: .spec.replicas
statusReplicasPath: .status.replicas
status: {}
33 changes: 24 additions & 9 deletions doc/apis.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ This document describes the types introduced by the WildFly Operator to be consu
[options="header,footer"]
|=======================
| Field | Description |Scheme| Required
| `metadata` | Standard objects metadata (https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata[more info]) | https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#objectmeta-v1-meta[metav1.ObjectMeta] | false
| `metadata` | Standard object's metadata (https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata[more info]) | https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#objectmeta-v1-meta[metav1.ObjectMeta] | false
| `spec` | Specification of the desired behaviour of the WildFly deployment (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status[more info]) | <<wildflyserverspec>> | true
| `status` | Most recent observed status of the WildFly deployment. Read-only. (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status#spec-and-status[more info]) | <<wildflyserverstatus>> | false |
| `status` | Most recent observed status of the WildFly deployment. Read-only. (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status#spec-and-status[more info]) | <<wildflyserverstatus>> | false |
|=======================

[[wildflyservelist]]
Expand All @@ -24,7 +24,7 @@ This document describes the types introduced by the WildFly Operator to be consu
[options="header,footer"]
|=======================
| Field | Description |Scheme| Required
| `metadata` | Standard list's metadata (https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata[more info]) | https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#listmeta-v1-meta[metav1.ListMeta] | false
| `metadata` | Standard list's metadata (https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata[more info]) | https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#listmeta-v1-meta[metav1.ListMeta] | false
| `items` | List of `WildFlyServer` | []<<wildflyserver>> | true
|=======================

Expand All @@ -44,16 +44,31 @@ It uses a `StatefulSet` with a pod spec that mounts the volume specified by `sto
| `bootableJar` | BootableJar specifies whether the application image is using WildFly S2I Builder/Runtime images or Bootable Jar. If omitted,
it defaults to false (application image is expected to use WildFly S2I Builder/Runtime images) | bool | false
| `standaloneConfigMap` | spec to specify how standalone configuration can be read from a `ConfigMap` | *<<standaloneconfigmapspec>> |false
| `resources`| Resources spec to specify the request or limits of the Stateful Set. If ommited, the namespace defaults are used. | *<<resources>> | false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I ask? From how this is documented here user can think there should be resources.resurces field. But in example there is just one field resources.

Shouldn't be here resources directly of type https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#resourcerequirements-v1-core[corev1.ResourceRequirements ? Analogous as env or envFrom?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@yersan yersan Feb 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mchoma,

I understand your concern, the key point here is that the value at the Scheme column is a pointer to another structure (notice it starts with *, and not a structure itself. So, resources is like *resources, which is indeed a https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#resourcerequirements-v1-core[corev1.ResourceRequirements

This specific case falls into these others:

It could be subtle for the user's thought, but after you run/check an example, you can realize it. Maybe having more quick examples could help with this.

Copy link
Collaborator

@yersan yersan Feb 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mchoma sorry, my explanation isn't really a good one; we indeed have resources -> *resources but then you see a field named as resources, and that can be confusing and make you think you have to use resources.resources to define it.

We could have resources -> *resources and then two fields like limits and requests or completely replace resources -> *resources by resources -> corev1.ResourceRequirements

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or completely replace resources -> *resources by resources -> corev1.ResourceRequirements

Yes that was my understanding what could be done to be consistent with rest.

We could have resources -> *resources and then two fields like limits and requests

TBH that sounds to me it will be less consistent with rest.

| `storage` | Storage spec to specify how storage should be used. If omitted, an `EmptyDir` is used (that will not persist data across pod restart) | *<<storagespec>> |false
| `serviceAccountName` | Name of the ServiceAccount to use to run the WildFlyServer Pods | string | false
| `envFrom` | List of environment variable present in the containers from source (either `ConfigMap` or `Secret`) | []https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#envfromsource-v1-core[corev1.EnvFromSource] |false
| `env` | List of environment variable present in the containers | []https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#envvar-v1-core[corev1.EnvVar] | false
| `serviceAccountName` | Name of the ServiceAccount to use to run the WildFlyServer Pods | string | false
| `envFrom` | List of environment variable present in the containers from source (either `ConfigMap` or `Secret`) | []https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#envfromsource-v1-core[corev1.EnvFromSource] |false
| `env` | List of environment variable present in the containers | []https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#envvar-v1-core[corev1.EnvVar] | false
| `secrets` | List of secret names to mount as volumes in the containers. Each secret is mounted as a read-only volume under `/etc/secrets/<secret name>` | string[] | false
| `configMaps` | List of ConfigMap names to mount as volumes in the containers. Each config map is mounted as a read-only volume under `/etc/configmaps/<config map name>` | string[] | false
| `disableHTTPRoute`| Disable the creation a route to the HTTP port of the application service (false if omitted) | bool | false
| `sessionAffinity`| If connections from the same client IP are passed to the same WildFlyServer instance/pod each time (false if omitted) | bool | false
|=======================

[[resources]]
## `Resources`

`Resources` defines the configured resources for a `WildflyServer` resources. If the resource is not defined or `Request` or `Limits` is empty this resources will removed from the `Stateful Set`
The description of this resource is a standard `Container` resource and is the same as the kubernetes api found on kubernetes.

This resource is not limited to only cpu and memory for more information on container resources:
https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/

[options="header,footer"]
|=======================
| Field | Description |Scheme| Required
| `resources` | ResourceRequirements describes the compute resource requirements. | https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#resourcerequirements-v1-core[corev1.ResourceRequirements] | false
|=======================

[[storagespec]]
## `StorageSpec`
Expand All @@ -68,8 +83,8 @@ transaction, make sure to specify a `volumeClaimTemplate` that so that the same
[options="header,footer"]
|=======================
| Field | Description |Scheme| Required
| `emptyDir` | EmptyDirVolumeSource to be used by the WildFly `StatefulSet` | https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#emptydirvolumesource-v1-core[*corev1.EmptyDirVolumeSource] | false
| `volumeClaimTemplate` | A PersistentVolumeClaim spec to configure `Resources` requirements to store WildFly standalone data directory. The name of the template is derived from the `WildFlyServer` name. The corresponding volume will be mounted in `ReadWriteOnce` access mode. | https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#persistentvolumeclaim-v1-core[corev1.PersistentVolumeClaim] | false
| `emptyDir` | EmptyDirVolumeSource to be used by the WildFly `StatefulSet` | https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#emptydirvolumesource-v1-core[*corev1.EmptyDirVolumeSource] | false
| `volumeClaimTemplate` | A PersistentVolumeClaim spec to configure `Resources` requirements to store WildFly standalone data directory. The name of the template is derived from the `WildFlyServer` name. The corresponding volume will be mounted in `ReadWriteOnce` access mode. | https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#persistentvolumeclaim-v1-core[corev1.PersistentVolumeClaim] | false
|=======================

[[standaloneconfigmapspec]]
Expand All @@ -80,7 +95,7 @@ transaction, make sure to specify a `volumeClaimTemplate` that so that the same
[options="header,footer"]
|=======================
| Field | Description |Scheme| Required
| `name` | Name of the `ConfigMap` containing the standalone configuration XML file. | string | true
| `name` | Name of the `ConfigMap` containing the standalone configuration XML file. | string | true
| `key` | Key of the ConfigMap whose value is the standalone configuration XML file. If omitted, the spec will look for the `standalone.xml` key. | string |false
|=======================

Expand Down
23 changes: 23 additions & 0 deletions doc/user-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,29 @@ spec:
replicas:2
----

[[resources]]
## Specify the Resource requirements for the container

The `resources` spec is defined in the link:../apis.adoc#Resources[Resources API Documentation].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reporting it @mchoma , I've just opened #217 to address this one and the others, both documents have broken links at several places.


[source,yaml]
.Example of resources configuration
```
spec:
resources:
limits:
cpu: 500m
memory: 2Gi
requests:
cpu: 100m
memory: 1Gi
```

For more examples visit:

* https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/
* https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/

[[storage]]
## Specify the Storage Requirements for the Server Data Directory

Expand Down
7 changes: 6 additions & 1 deletion pkg/apis/wildfly/v1alpha1/wildflyserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ type WildFlyServerSpec struct {
// +kubebuilder:validation:MinItems=1
// +listType=set
ConfigMaps []string `json:"configMaps,omitempty"`
// ResourcesSpec defines the resources used by the WildFlyServer, ie CPU and memory, use limits and requests.
// More info: https://pkg.go.dev/k8s.io/[email protected]/core/v1#ResourceRequirements
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
}

// StandaloneConfigMapSpec defines the desired configMap configuration to obtain the standalone configuration for WildFlyServer
Expand Down Expand Up @@ -83,6 +86,8 @@ type WildFlyServerStatus struct {
//
// Read-only.
ScalingdownPods int32 `json:"scalingdownPods"`
// selector for pods, used by HorizontalPodAutoscaler
Selector string `json:"selector"`
}

const (
Expand Down Expand Up @@ -119,7 +124,7 @@ type PodStatus struct {
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:subresource:status
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector
// +kubebuilder:printcolumn:name="Replicas",type="integer",JSONPath=".spec.replicas"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:resource:shortName=wfly
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/wildfly/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 28 additions & 15 deletions pkg/apis/wildfly/v1alpha1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkg/controller/wildflyserver/wildflyserver_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ func (r *ReconcileWildFlyServer) Reconcile(request reconcile.Request) (reconcile
return r.manageError(wildflyServer, err)
}

// Use the unique CR name as the selector label, must be implemented in the pods as well.
wildflyServer.Status.Selector = fmt.Sprintf("app.kubernetes.io/name=%s", wildflyServer.Name)

// If statefulset was deleted during processing recovery scaledown the number of replicas in WildflyServer spec
// does not defines the number of pods which should be left active until recovered
desiredReplicaSizeForNewStatefulSet := wildflyServer.Spec.Replicas + wildflyServer.Status.ScalingdownPods
Expand Down
Loading