Skip to content

Commit

Permalink
License support - tests and README update
Browse files Browse the repository at this point in the history
  • Loading branch information
devdattakulkarni committed Aug 3, 2024
1 parent 432f2de commit 18f016a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The KubePlus Operator does not need any admin-level permissions on a cluster for

### Resource utilization

KubePlus provides controls to set per-namespace resource quotas. It also monitors usage of CPU, memory, storage, and network traffic at the application instance level. The collected metrics are available in different formats and can be pulled into Prometheus for historical usage tracking.
KubePlus provides controls to set per-namespace resource quotas. It also monitors usage of CPU, memory, storage, and network traffic at the application instance level. The collected metrics are available in different formats and can be pulled into Prometheus for historical usage tracking. KubePlus also supports ability to define licenses for the CRDs. A license defines the number of application instances that can be created for that CRD, and an expiry date. KubePlus prevents creation of application instances if the license terms are not met.

### Upgrades

Expand All @@ -37,7 +37,8 @@ A new version of an application can be deployed by updating the application Helm

### Customization

The spec properties of the Kubernetes CRD wrapping the application Helm chart are the fields defined in the chart’s values.yaml file. Application deployments can be customized by specifying different values for these spec properties. KubePlus also supports ability to define licenses for the CRDs. A license defines the number of application instances that can be created for that CRD, and an expiry date. KubePlus prevents creation of application instances if the license terms are not met.
The spec properties of the Kubernetes CRD wrapping the application Helm chart are the fields defined in the chart’s values.yaml file. Application deployments can be customized by specifying different values for these spec properties.


## Demo

Expand Down
38 changes: 24 additions & 14 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,20 @@ def count_users(response):
num_users += 1
return num_users

def cleanup():
cmd = 'kubectl delete -f ./application-upgrade/resource-composition-localchart.yaml --kubeconfig=./application-upgrade/provider.conf'
TestKubePlus.run_command(cmd)

# restore chart
data = None
with open('./application-upgrade/resource-composition-localchart.yaml', 'r') as f:
data = yaml.safe_load(f)

data['spec']['newResource']['chartURL'] = 'file:///resource-composition-0.0.1.tgz'

with open('./application-upgrade/resource-composition-localchart.yaml', 'w') as f:
yaml.safe_dump(data, f, default_flow_style=False)

# preliminary checks
if not TestKubePlus._is_kubeplus_running():
print("KubePlus is not running. Deploy KubePlus and then run tests")
Expand Down Expand Up @@ -298,7 +312,8 @@ def count_users(response):
port = 5000

# let the app pods come up
time.sleep(30)
wait_time = 60
time.sleep(wait_time)

# grab name of deployed pod
cmd = "kubectl get pods -n %s" % namespace
Expand All @@ -312,6 +327,12 @@ def count_users(response):
name = part.strip()
break

print("Pod name:" + name)
if name == None:
print("Pod did not come up even after waiting " + str(wait_time) + " seconds.")
print("Skipping rest of the test.")
cleanup()

# port forwarding
# CLI: kubectl port-forward pod-name -n bwa-tenant1 5000:5000
config.load_kube_config()
Expand All @@ -320,6 +341,7 @@ def count_users(response):
Configuration.set_default(c)
api_instance = core_v1_api.CoreV1Api()


# https://github.com/kubernetes-client/python/blob/master/examples/pod_portforward.py
pf = portforward(api_instance.connect_get_namespaced_pod_portforward,
name,
Expand Down Expand Up @@ -365,19 +387,7 @@ def count_users(response):
response = make_http_request(port).strip(" ")
num_users_second = count_users(response)

# cleanup
cmd = 'kubectl delete -f ./application-upgrade/resource-composition-localchart.yaml --kubeconfig=./application-upgrade/provider.conf'
TestKubePlus.run_command(cmd)

# restore chart
data = None
with open('./application-upgrade/resource-composition-localchart.yaml', 'r') as f:
data = yaml.safe_load(f)

data['spec']['newResource']['chartURL'] = 'file:///resource-composition-0.0.1.tgz'

with open('./application-upgrade/resource-composition-localchart.yaml', 'w') as f:
yaml.safe_dump(data, f, default_flow_style=False)
cleanup()

# check if upgrade worked
self.assertTrue(num_users_second > num_users_first)
Expand Down

0 comments on commit 18f016a

Please sign in to comment.