hostpath-provisioner-operator

module
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2021 License: Apache-2.0

README

hostpath-provisioner-operator

The Kubernetes operator for managing KubeVirt hostpath provisioner deployment. Leverages the operator-sdk.

How to deploy

Before deploying the operator, you need to create the hostpath provisioner namespace:

$ kubectl create -f https://raw.githubusercontent.com/kubevirt/hostpath-provisioner-operator/master/deploy/namespace.yaml

And then you can create the operator:

$ kubectl create -f https://raw.githubusercontent.com/kubevirt/hostpath-provisioner-operator/master/deploy/operator.yaml -n hostpath-provisioner

If you want to change the namespace in which you create the provisioner, make sure to update the ClusterRoleBinding and RoleBinding namespaces in the operator.yaml to match your namespace. Also change the namespace by changing the -n argument

Once you have installed the operator, you need to create an instance of the Custom Resource to deploy the hostpath provisioner in the hostpath-provisioner namespace.

Custom Resource (CR)

Example CR allows you specify the directory you wish to use as the backing directory for the persistent volumes. You can also specify if you wish to use the name of the PersistentVolume as part of the directory that is created by the provisioner. All the values in the spec are required. The location of provisioner container is defined in the deploy/operator.yaml file

apiVersion: hostpathprovisioner.kubevirt.io/v1beta1
kind: HostPathProvisioner
metadata:
  name: hostpath-provisioner
spec:
  imagePullPolicy: IfNotPresent
  pathConfig:
    path: "/var/hpvolumes" #The path of the directory on the node
    useNamingPrefix: false #Use the name of the PVC bound to the created PV as part of the directory name.

To create the CustomResource

$ kubectl create -f https://raw.githubusercontent.com/kubevirt/hostpath-provisioner-operator/master/deploy/hostpathprovisioner_cr.yaml -n hostpath-provisioner

Once the CustomResource has been created, the operator will deploy the provisioner as a DaemonSet on each node.

Storage Class

The hostpath provisioner supports two volumeBindingModes, Immediate and WaitForFirstConsumer. In general WaitForFirstConsumer is preferred however this requires Kubernetes >= 1.12 and if one is running an older kubernetes that volumeBindingMode will not work. Immediate binding mode is now deprecated and may be removed in the future. For this reason the operator will not create the StorageClass for you and you will have to do it yourself. Example storageclass yamls are available in deploy directory in this repository.

SELinux

On each node you will have to give the directory you specify in the CR the appropriate selinux rules by running the following (assuming you pick /var/hpvolumes as your PathConfig path):

$ sudo chcon -t container_file_t -R /var/hpvolumes

Another way to configure SELinux when using OpenShift is using a MachineConfig.

Deployment in OpenShift

The operator will create the appropriate SecurityContextConstraints for the hostpath provisioner to work and assign the ServiceAccount to that SCC. This operator will only work on OpenShift 4 and later (Kubernetes >= 1.12).

Directories

Path Synopsis
cmd
pkg
apis/hostpathprovisioner
Package hostpathprovisioner contains hostpathprovisioner API versions.
Package hostpathprovisioner contains hostpathprovisioner API versions.
apis/hostpathprovisioner/v1alpha1
Package v1alpha1 contains API Schema definitions for the hostpathprovisioner v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=hostpathprovisioner.kubevirt.io
Package v1alpha1 contains API Schema definitions for the hostpathprovisioner v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=hostpathprovisioner.kubevirt.io
apis/hostpathprovisioner/v1beta1
Package v1beta1 contains API Schema definitions for the hostpathprovisioner v1beta1 API group +k8s:deepcopy-gen=package,register +groupName=hostpathprovisioner.kubevirt.io
Package v1beta1 contains API Schema definitions for the hostpathprovisioner v1beta1 API group +k8s:deepcopy-gen=package,register +groupName=hostpathprovisioner.kubevirt.io
client/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
client/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
client/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
client/clientset/versioned/typed/hostpathprovisioner/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/hostpathprovisioner/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
client/clientset/versioned/typed/hostpathprovisioner/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/hostpathprovisioner/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
util
* This file is part of the KubeVirt project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* This file is part of the KubeVirt project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL