The hull.objects section
The top-level object types beneath hull.objects represent the supported Kubernetes object types you might want to create instances from. Each object type is a dictionary where the entries values are the objects properties and each object has it's own key which is unique to the object type it belongs to. Further K8S object types can be added as needed to the library so it can easily be extended.
Keys of object instances
One important aspect is that for all top-level object types, instances of a particular type are always identified by a key which is unique to the instance and object type combination. The same key can however be used for instances of different object types.
By having keys that identify instances you can:
- do multi-layered merging of object properties by stacking
values.yamlfiles on top of each other. You might start with defining the default object structure of the application or micro service defined in the given helm chart. Then you might add avalues.yamllayer for a particular environment like staging or production. Then you might add avalues.yamllayer for credentials. And so on. By uniquely identifying the instances of a particular K8s object type it becomes easy to adjust the objects properties through a multitude of layers. - use the key of an instance for naming the instance. All instance names are constructed by the following ground rule:
{{ printf "%s-%s-%s" .Release.Name .Chart.Name key }}. This generates unique, dynamic names per object type and release + instance key combination.
For example, assuming the parent Helm chart is named my_webservice and the release named staging and given this specification in values.yaml:
hull:
objects:
deployment:
nginx:
pod:
containers:
nginx:
repository: nginx
tag: 1.14.2
a Kubernetes deployment object with the following metadata.name is created:
my_webservice-staging-nginx
Note that you can opt to define a static name for instances you create by adding a property
staticName: trueto your objects definition. If you do so the objects name will exactly match the key name you chose.
-
each particular instance can have an
enabledsub-field set totrueorfalse. This way you can predefine instances of object types in your helm chartsvalues.yamlbut not deploy them in a default scenario. Or enable them by default and refrain from deploying them in a particular environment by disabling them in an superimposed system specificvalues.yaml. Note that unless you explicitly specifyenabled: falseeach instance you define will be created by default, a missingenabledkey is equivalent toenabled: true. -
cross-referencing objects within a helm chart by the instance key is a useful feature of the HULL library. This is possible in these contexts:
- when a reference to a ConfigMap or Secret comes into play you can just use the key of the targeted instance and the dynamic name will be rendered in the output. This is possible for referencing
- a ConfigMap or Secret behind a Volume or
- a Secret behind an Ingress' TLS specification or
- a ConfigMap or Secret behind an environment value added to a container spec.
-
when referencing Services in the backend of an ingress' host you can specify the key to reference the backend service.
Note that you can in these cases opt to refer to a static name instead too. Adding a property
staticName: trueto the dictionary with your reference will force the referenced objects name to exactly match the name you entered.
Values of object instances
The values of object instance keys reflects the Kubernetes objects to create for the chart. To specify these objects efficiently, the available properties for configuration can be split into three groups:
-
Basic HULL object configuration with hull.ObjectBase.v1 whose properties are available for all object types and instances. These are
enabled,staticName,annotationsandlabels.Given the example of a
deploymentnamednginxyou can add the following properties of hull.ObjectBase.v1 to the object instance:hull: objects: deployment: nginx: # unique key/identifier of the deployment to create staticName: true # property of hull.ObjectBase.v1 # forces the metadata.name to be just the <KEY> 'nginx' # and not a dynamic name '<CHART>-<RELEASE>-<KEY>' which # would be the better default behavior of creating # unique object names for all objects. enabled: true # property of hull.ObjectBase.v1 # this deployment will be rendered to a YAML object if enabled labels: demo_label: "demo" # property of hull.ObjectBase.v1 # add all labels here that shall be added # to the object instance metadata section annotations: demo_annotation: "demo" # property of hull.ObjectBase.v1 # add all annotations here that shall be added # to the object instance metadata section pod: ... # Here would come the hull.PodTemplate.v1 definition # see below for details -
Specialized HULL object properties for some object types. Below is a reference of which object type supports which special properties in addition to the basic object configuration.
Again given the example of a
deploymentnamednginxyou would want to add properties of the HULL hull.PodTemplate.v1 to the instance. With them you set thepodproperty to define the pod template (initContainers, containers, volumes, ...) and can addtemplateLabelsandtemplateAnnotationsjust to the pods createdmetadataand not the deployment objectsmetadatasection:hull: objects: deployment: nginx: staticName: true enabled: true labels: demo_label: "demo" annotations: demo_annotation: "demo" templateLabels: # property of hull.PodTemplate.v1 to define # labels only added to the pod demo_pod_label: "demo pod" templateAnnotations: # property of hull.PodTemplate.v1 to define # annotations only added to the pod demo_pod_annotation: "demo pod" pod: # property of hull.PodTemplate.v1 to define the pod template containers: nginx: # all containers of a pod template are also referenced by a # unique key to make manipulating them easy. image: repository: nginx # specify repository and tag # separately with HULL for easier composability tag: 1.14.2 ... # further properties (volumeMounts, affinities, ...) -
Kubernetes object properties. For each object type it is basically possible to specify all existing Kubernetes properties. In case a HULL property overwrites a identically named Kubernetes property the HULL property has precedence. Even if a HULL property overrides a Kubernetes property it is intended to provide the same complete configuration options, even if sometimes handled differently by HULL.
Some of the typical top-level Kubernetes object properties and fields don't require setting them with HULL based objects because they can be deducted automatically: - the
apiVersionandkindare determined by the HULL object type and Kubernetes API version and don't require to be explicitly set (except for objects of typecustomresource). - the top-levelmetadatadictionary on objects is handled by HULL via theannotationsandlabelsfields and the naming rules explained above. So themetadatafield does not require configuration and is hence not configurable for any object.Some lower level structures are also converted from the Kubernetes API array form to a dictionary form or are modified to improve working with them. This also enables more sophisticated merging of layers since arrays don't merge well, they only can be overwritten completely. Overwriting arrays however can make it hard to forget about elements that are contained in the default form of the array (you would need to know that they existed in the first place). In short, for a layered configuration approach without an endless amount of elements the dictionary is preferable for representing data since it offers a much better merging support.
So again using the example of a
deploymentnamednginxyou can add the remaining available Kubernetes properties to the object instance which are not handled by HULL as shown below. For adeploymentspecifically you can add all the remaining properties defined in thedeploymentspecAPI schema from deploymentspec-v1-apps which areminReadySeconds,paused,progressDeadlineSeconds,replicas,revisionHistoryLimitandstrategy. If properties are marked as mandatory in the Kubernetes JSON schema you must provide them otherwise the rendering process will fail:hull: objects: deployment: nginx: staticName: true enabled: true labels: demo_label: "demo" annotations: demo_annotation: "demo" pod: ... # Here would come the hull.PodTemplate.v1 definition # see above for details replicas: 3 # property from the Kubernetes API deploymentspec strategy: # property from the Kubernetes API deploymentspec type: Recreate ... # further Kubernetes API deploymentspec options
Composing objects with HULL
Here is an overview of which top level properties are available for which object type in HULL. The HULL properties are grouped by the respective HULL JSON schema group they belong to. A detailed description of these groups and their properties is found in the documentation of this helm chart and the respective linked documents.
Admissionregistration APIs
| HULL Object Type |
HULL Properties |
Kubernetes/External Properties |
|---|---|---|
mutatingadmissionpolicy |
hull.ObjectBase.v1enabledannotationslabelsstaticNamemutatingadmissionpolicyspec-v1-admissionregistration failurePolicymatchConditionsmatchConstraintsmutationsparamKindreinvocationPolicyvariables |
|
mutatingadmissionpolicybinding |
hull.ObjectBase.v1enabledannotationslabelsstaticNamemutatingadmissionpolicybindingspec-v1-admissionregistration matchResourcesparamRefpolicyName |
|
mutatingwebhookconfiguration |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.MutatingWebhook.v1 webhooks |
|
validatingadmissionpolicy |
hull.ObjectBase.v1enabledannotationslabelsstaticNamevalidatingadmissionpolicyspec-v1-admissionregistration auditAnnotationsfailurePolicymatchConditionsmatchConstraintsparamKindvalidationsvariables |
|
validatingadmissionpolicybinding |
hull.ObjectBase.v1enabledannotationslabelsstaticNamevalidatingadmissionpolicybindingspec-v1-admissionregistration matchResourcesparamRefpolicyNamevalidationActions |
|
validatingwebhookconfiguration |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.ValidatingWebhook.v1 webhooks |
Apps APIs
| HULL Object Type |
HULL Properties |
Kubernetes/External Properties |
|---|---|---|
daemonset |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.PodTemplate.v1 templateAnnotationstemplateLabelspod |
daemonsetspec-v1-appsminReadySecondsordinalsrevisionHistoryLimitupdateStrategy |
deployment |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.PodTemplate.v1 templateAnnotationstemplateLabelspod |
deploymentspec-v1-appsminReadySecondspausedprogressDeadlineSecondsreplicasrevisionHistoryLimitstrategy |
statefulset |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.PodTemplate.v1 templateAnnotationstemplateLabelspod |
statefulsetspec-v1-appspodManagementPolicyreplicasrevisionHistoryLimitserviceNameupdateStrategyserviceNamevolumeClaimTemplates |
Autoscaling APIs
| HULL Object Type |
HULL Properties |
Kubernetes/External Properties |
|---|---|---|
horizontalpodautoscaler |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.HorizontalPodAutoscaler.v1 scaleTargetRef |
horizontalpodautoscalerspec-v2-autoscalingbehaviormaxReplicasmetricsminReplicas |
Batch APIs
| HULL Object Type |
HULL Properties |
Kubernetes/External Properties |
|---|---|---|
job |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.PodTemplate.v1 templateAnnotationstemplateLabelspod |
jobspec-v1-batchactiveDeadlineSecondsbackoffLimitcompletionModecompletionsmanualSelectorparallelismselectorsuspendttlSecondsAfterFinished |
cronjob |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.Job.v1 job |
cronjobspec-v1-batchconcurrencyPolicyfailedJobsHistoryLimitschedulestartingDeadlineSecondssuccessfulJobsHistoryLimitsuspend |
Core APIs
| HULL Object Type |
HULL Properties |
Kubernetes/External Properties |
|---|---|---|
configmap |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.VirtualFolder.v1 data |
configmap-v1-corebinaryDataimmutable |
endpoints(deprecated since K8S 1.33) |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
endpoints-v1-coresubsets |
limitrange |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
limitrange-v1-corelimits |
namespace |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
namespace-v1-corespecstatus |
persistentvolume |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
persistentvolumespec-v1-coreaccessModesawsElasticBlockStoreazureDiskazureFilecapacitycephfscinderclaimRefcsifcflexVolumeflockergcePersistentDiskglusterfshostPathiscsilocalmountOptionsnfsnodeAffinitypersistentVolumeReclaimPolicyphotonPersistentDiskportworxVolumequobyterbdscaleIOstorageClassNamestorageosvolumeModevsphereVolume |
persistentvolumeclaim |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
persistentvolumeclaimspec-v1-coreaccessModesdataSourceresourcesselectorstorageClassNamevolumeModevolumeName |
resourcequota |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
resourcequotaspec-v1-corehardscopeSelectorscopes |
secret |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.VirtualFolder.v1 data |
secret-v1-coreimmutablestringDatatype |
service |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.Service.v1 ports |
servicespec-v1-coreallocateLoadBalancerNodePortsclusterIPclusterIPsexternalIPsexternalNameexternalTrafficPolicyhealthCheckNodePortinternalTrafficPolicyipFamiliesipFamilyPolicyloadBalancerClassloadBalancerIPloadBalancerSourceRangespublishNotReadyAddressesselectorsessionAffinitysessionAffinityConfigtopologyKeystype |
serviceaccount |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
serviceaccount-v1-coreautomountServiceAccountTokenimagePullSecretssecrets |
Discovery APIs
| HULL Object Type |
HULL Properties |
Kubernetes/External Properties |
|---|---|---|
endpointslice |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
endpointslice-v1-discovery-k8s-ioaddressTypeendpointsports |
Networking APIs
| HULL Object Type |
HULL Properties |
Kubernetes/External Properties |
|---|---|---|
ingress |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.Ingress.v1 tlsrules |
ingressspec-v1-networking-k8s-iodefaultBackendingressClassName |
ingressclass |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
ingressclassspec-v1-networking-k8s-iocontrollerparameters |
networkpolicy |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
networkpolicyspec-v1-networking-k8s-ioegressingresspodSelectorpolicyTypes |
Policy APIs
| HULL Object Type |
HULL Properties |
Kubernetes/External Properties |
|---|---|---|
poddisruptionbudget |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
poddisruptionbudgetspec-v1-policymaxUnavailableminAvailableselectorunhealthyPodEvictionPolicy |
RBAC APIs
| HULL Object Type |
HULL Properties |
Kubernetes/External Properties |
|---|---|---|
clusterrole |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.Rule.v1 rules |
clusterrole-v1-rbac-authorization-k8s-ioaggregationRule |
clusterrolebinding |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
clusterrolebinding-v1-rbac-authorization-k8s-ioroleRefsubjects |
role |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.Rule.v1 rules |
role-v1-rbac-authorization-k8s-io |
rolebinding |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
rolebinding-v1-rbac-authorization-k8s-ioroleRefsubjects |
Scheduling APIs
| HULL Object Type |
HULL Properties |
Kubernetes/External Properties |
|---|---|---|
priorityclass |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
priorityclass-v1-scheduling-k8s-iodescriptionglobalDefaultpreemptionPolicyvalue |
Storage APIs
| HULL Object Type |
HULL Properties |
Kubernetes/External Properties |
|---|---|---|
storageclass |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
storageclass-v1-storage-k8s-ioallowVolumeExpansionallowedTopologiesmountOptionsparametersprovisionerreclaimPolicyvolumeBindingMode |
HULL Extensions APIs
| HULL Object Type |
HULL Properties |
Kubernetes/External Properties |
|---|---|---|
customresource |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.CustomResource.v1 apiVersionkindspec |
|
generic |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.Generic.v1 apiVersionkind |
|
registry |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.Registry.v1 serverusernamepassword |
Gateway APIs
| HULL Object Type |
HULL Properties |
Kubernetes/External Properties |
|---|---|---|
backendlbpolicy |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.BackendLBPolicy.v1alpha2 targetRefs |
backendlbpolicyspec-v1alpha2-gateway-networking-k8s-iosessionPersistence |
backendtlspolicy |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.BackendTLSPolicy.v1alpha3 targetRefs |
backendtlspolicyspec-v1alpha3-gateway-networking-k8s-iooptionsvalidation |
gatewayclass |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
gatewayclassspec-v1-gateway-networking-k8s-iocontrollerNamedescriptionparametersRef |
gateway |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.Gateway.v1 addresseslisteners |
gatewayspec-v1-gateway-networking-k8s-iobackendTLSgatewayClassNameinfrastructure |
grpcroute |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.GRPCRoute.v1 hostnamesparentRefsrules |
|
httproute |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.HTTPRoute.v1 hostnamesparentRefsrules |
|
referencegrant |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.ReferenceGrant.v1beta1 fromto |
|
tcproute |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.TCPRoute.v1alpha2 parentRefsrules |
|
tlsroute |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.TLSRoute.v1alpha2 hostnamesparentRefsrules |
|
udproute |
hull.ObjectBase.v1enabledannotationslabelsstaticNamehull.UDPRoute.v1alpha2 parentRefsrules |
Third Party APIs
| HULL Object Type |
HULL Properties |
Kubernetes/External Properties |
|---|---|---|
servicemonitor |
hull.ObjectBase.v1enabledannotationslabelsstaticName |
ServiceMonitor CRDspec |
Back to README.md