Create Custom Resource in Kubernetes
The operator needs a resource file that declares the customary resources of the cluster that you created in Kubernetes. The operator uses this custom resource file to declare the kubernetes cluster with your desired state.
To make sure the operator gets access to custom resources, you need to create a manifest file and deploy it in the cluster. Follow the steps provided below:
Create Manifest File for Custom Resources
ncache_custom_resource.yaml file lists the desired state of your kubernetes cluster under the spec
section.
Note
The parameters required to create this YAML file, ready to be deployed, are explained in the Properties section.
kind: NCache
apiVersion: alachisoft.ncache/v1
metadata:
name: ncache
spec:
# Add fields here
clusterSize: 1
image: enterprise-server-5.2-linux # NCache container image
nodeSelector:
kubernetes.io/os: linux
podRequests:
memory: "512Mi"
cpu: 1
podLimits:
memory: "512Mi"
cpu: 1
debug:
enable: false
parameters:
'{"registrationInfo": {"email": "john_smith@yourcompany.com","firstName": "John","lastName": "Smith","company": "Your Company","environment": "Production","clientLicenses": "8", "licenseKey": "xxxxxxx-xxxxxxx-xxxxxxx"}}'
Note
You can provide Evaluation Key instead of License Key in the parameters
section to activate NCache in evaluation mode.
"evaluationKey": "xxxxxxxxxxxxxxxxxxxxxxxxxx"
Deploy Custom Resources in Kubernetes
To deploy the desired state specified in the ncache_custom_resource.yaml, you need to execute the following command in the cloud shell:
kubectl create -f [dir]/ncache_custom_resource.yaml
On execution of this command, the operator will activate your NCache cluster using the registration information provided in the custom resource file.
For verification, run the following command:
kubectl get pods -w
Properties
The properties required to create and deploy a custom resource in your Kubernetes cluster are explained below:
Parameter | Description |
---|---|
-kind |
Specifies the kind of custom resource to deploy. In this case, it is NCache. |
-apiVersion |
Specifies the version of the custom resource that is to be deployed in k8s. |
-name |
Specifies the name of the deployment. |
-clusterSize |
Specifies the number of servers of the NCache cluster. |
-image |
Specifies the path of the container image of NCache. |
-nodeSelector |
Specifies the node on which the underlying container needs to be hosted. |
-podRequests |
Specifies the limits on requests required at the time of scheduling. |
-podLimits |
Specifies the limits on pods. If this is not provided, the pod will use the maximum memory and CPU limit. |
-parameters |
Specifies the registration information to install NCache in the container. |
The next step is to deploy the NCache client in your Kubernetes cluster, the steps of which have been explained in the next chapter.
See Also
Create Role Definition in Kubernetes
Create Service Account in Kubernetes
Create Custom Resource in Kubernetes