Skip to content

Commit 9296f83

Browse files
committed
* Add support for installing OpenCost alongside KubePlus
* Create a script for installing the KubePlus operator and KubePlus kubectl plugin * Update README.md to include a "Quick Installation" section and move the getting-started example to a separate file to streamline the README * Add an OpenCost example to the getting-started file * Update GitHub Actions PR workflow to use the install.sh script for installing the KubePlus operator and kubectl plugin; modularized into distinct steps
1 parent 34f6dce commit 9296f83

4 files changed

Lines changed: 444 additions & 200 deletions

File tree

.github/workflows/pr.yaml

Lines changed: 103 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,116 +4,162 @@ on:
44
env:
55
ACTIONS_RUNNER_DEBUG: true
66
KUBEPLUS_TEST_OUTPUT: yes
7+
KUBEPLUS_CI: true
78
jobs:
89
job1:
910
runs-on: ubuntu-20.04
1011
name: Deploy to minikube
1112
steps:
12-
- uses: actions/checkout@v2
13-
- name: Start minikube
14-
uses: medyagh/setup-minikube@master
15-
- name: Try the cluster !
13+
- name: Checkout Code
14+
uses: actions/checkout@v4
15+
16+
- name: Create k8s Kind Cluster
17+
uses: helm/kind-action@v1
18+
19+
- name: Verify Cluster
1620
run: kubectl get pods -A
17-
- name: Deploy KubePlus and application to minikube
18-
run: |
19-
export SHELL=/bin/bash
20-
eval $(minikube -p minikube docker-env)
21-
echo "Glibc version"
22-
ldd --version
23-
sudo apt-get install python3-lxml
24-
echo "Installing helm..."
21+
22+
- name: Display Glibc Version
23+
run: ldd --version
24+
25+
- name: Install Python3 LXML
26+
run: sudo apt-get install python3-lxml
27+
28+
- name: Install Helm
29+
run: |
30+
echo "Installing Helm..."
2531
wget https://get.helm.sh/helm-v3.12.1-linux-amd64.tar.gz
2632
gunzip helm-v3.12.1-linux-amd64.tar.gz
2733
tar -xvf helm-v3.12.1-linux-amd64.tar
2834
sudo mv linux-amd64/helm /usr/local/bin/.
29-
echo "Installing golang..."
30-
rm -rf /usr/local/go
35+
36+
- name: Install Golang
37+
run: |
38+
echo "Installing Golang..."
39+
rm -rf /usr/local/go
3140
wget https://go.dev/dl/go1.22.4.linux-amd64.tar.gz
3241
sudo tar -C /usr/local -xzf go1.22.4.linux-amd64.tar.gz
3342
export PATH=$PATH:/usr/local/go/bin
3443
go version
44+
45+
- name: Prepare KubePlus Environment
46+
run: |
47+
echo "Setting up KubePlus environment..."
3548
echo "Current directory:`pwd`"
36-
echo "Folders:`ls`"
37-
kubeplus_folder="$(basename `pwd`)"
38-
echo "KubePlus folder name:$kubeplus_folder"
3949
mkdir -p $HOME/go/src/github.com/cloud-ark
4050
cd ..
41-
runner_dir=`pwd`
4251
echo "Current directory:`pwd`"
43-
mv $kubeplus_folder $HOME/go/src/github.com/cloud-ark/kubeplus
52+
kubeplus_folder="$(basename `pwd`)"
53+
echo "KubePlus folder name:$kubeplus_folder"
54+
cp -R $kubeplus_folder $HOME/go/src/github.com/cloud-ark/kubeplus
4455
cd $HOME/go/src/github.com/cloud-ark/kubeplus
56+
export KUBEPLUS_NS=default
4557
export KUBEPLUS_HOME=`pwd`
4658
export PATH=$KUBEPLUS_HOME/plugins:$PATH
4759
echo "PATH:$PATH"
48-
echo "KUBEPLUS_HOME:$KUBEPLUS_HOME"
49-
kubectl kubeplus commands
50-
export KUBEPLUS_NS=default
51-
python3 -m venv venv
52-
source venv/bin/activate
53-
pip3 install -r requirements.txt
54-
apiserver=`kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}'`
55-
echo "API_SERVER_URL:$apiserver"
56-
python3 provider-kubeconfig.py -s $apiserver create $KUBEPLUS_NS
57-
deactivate
5860
59-
echo "Building mutating-webhook..."
61+
- name: Build Mutating Webhook
62+
run: |
63+
echo "KUBEPLUS_HOME:$KUBEPLUS_HOME"
6064
cd $KUBEPLUS_HOME/mutating-webhook
61-
export GO111MODULE=on; go get github.com/googleapis/gnostic@v0.4.0
65+
export GO111MODULE=on
66+
go get github.com/googleapis/gnostic@v0.4.0
6267
./build-artifact.sh latest
6368
64-
echo "Building helmer..."
69+
- name: Build Helmer
70+
run: |
6571
cd $KUBEPLUS_HOME/platform-operator/helm-pod/
6672
go mod vendor
6773
./build-artifact.sh latest
6874
69-
echo "Building platform-operator..."
75+
- name: Build Platform Operator
76+
run: |
7077
cd $KUBEPLUS_HOME/platform-operator
7178
./build-artifact.sh latest
7279
73-
echo "Building kubeconfiggenerator..."
80+
- name: Build KubeConfig Generator
81+
run: |
7482
cd $KUBEPLUS_HOME/deploy
7583
./build-artifact-kubeconfiggenerator.sh latest
76-
#echo "Building webhook_init_container..."
77-
#./build-artifact.sh latest
78-
#echo "Building resource cleaner..."
79-
#./build-artifact-clean.sh latest
80-
81-
#cd $KUBEPLUS_HOME/consumerui
82-
#echo "Building consumer ui..."
83-
#./build-artifact.sh latest
8484
85+
- name: List Docker Images
86+
run: |
8587
cd $KUBEPLUS_HOME
86-
ls
8788
docker images
8889
89-
echo "Installing KubePlus..."
90-
helm install kubeplus ./deploy/kubeplus-chart --kubeconfig=kubeplus-saas-provider.json --set MUTATING_WEBHOOK=gcr.io/cloudark-kubeplus/pac-mutating-admission-webhook:latest --set PLATFORM_OPERATOR=gcr.io/cloudark-kubeplus/platform-operator:latest --set HELMER=gcr.io/cloudark-kubeplus/helm-pod:latest --set CRD_REGISTRATION_HELPER=gcr.io/cloudark-kubeplus/kubeconfiggenerator:latest -n $KUBEPLUS_NS
90+
- name: Deploy KubePlus, Prometheus, and OpenCost to minikube
91+
run: |
92+
echo "Deploying KubePlus, Prometheus, and OpenCost..."
93+
wget https://raw.githubusercontent.com/opencost/opencost/develop/configs/default.json
94+
./install.sh --prometheus --opencost default.json --kubeplus-plugin --kubeplus $KUBEPLUS_NS
9195
92-
kubectl get pods -A
96+
- name: Verify Prometheus Installation
97+
run: |
98+
echo "Verifying Prometheus installation..."
99+
kubectl get pods -n prometheus-system | grep prometheus
93100
94-
until kubectl get pods -A | grep kubeplus | grep -i Running; do echo "Waiting for KubePlus to start.."; sleep 1; kubeplus_pod=`kubectl get pods | grep kubeplus | awk '{print $1}'`; kubectl get pods $kubeplus_pod; done
101+
- name: Verify OpenCost Installation
102+
run: |
103+
echo "Verifying OpenCost installation..."
104+
kubectl get pods -n opencost | grep opencost
105+
106+
- name: Verify KubePlus Installation
107+
run: |
108+
echo "Verifying KubePlus installation..."
109+
kubectl get pods -n $KUBEPLUS_NS | grep kubeplus
110+
111+
- name: Retrieve KubePlus Pod Logs
112+
run: |
95113
kubeplus_pod=`kubectl get pods | grep kubeplus | awk '{print $1}'`
96-
echo "helmer logs..."
114+
echo "Helmer logs..."
97115
kubectl logs $kubeplus_pod -c helmer
98-
echo "platform-operator logs..."
116+
echo "Platform Operator logs..."
99117
kubectl logs $kubeplus_pod -c platform-operator
100-
echo "crd-hook logs..."
118+
echo "CRD Hook logs..."
101119
kubectl logs $kubeplus_pod -c crd-hook
102-
kubectl upload chart ./examples/multitenancy/application-hosting/wordpress/wordpress-chart-0.0.3.tgz kubeplus-saas-provider.json
103-
echo "Sleeping for 10 seconds before continuing..."
104-
sleep 10
120+
121+
- name: Upload Example Chart
122+
run: kubectl upload chart ./examples/multitenancy/application-hosting/wordpress/wordpress-chart-0.0.3.tgz kubeplus-saas-provider.json
123+
124+
- name: Sleep Before Continuing
125+
run: sleep 10
126+
127+
- name: Deploy WordPress Service Composition
128+
run: |
105129
kubectl create -f ./examples/multitenancy/application-hosting/wordpress/wordpress-service-composition-localchart.yaml --kubeconfig=kubeplus-saas-provider.json
106-
until kubectl get crds | grep wordpressservices.platformapi.kubeplus; do echo "Waiting for CRD to be registered.."; sleep 1; done
130+
131+
- name: Wait for CRD Registration
132+
run: |
133+
until kubectl get crds | grep wordpressservices.platformapi.kubeplus; do
134+
echo "Waiting for CRD to be registered..."
135+
sleep 1
136+
done
137+
138+
- name: Deploy Tenant Example
139+
run: |
107140
kubectl create -f ./examples/multitenancy/application-hosting/wordpress/tenant1.yaml --kubeconfig=kubeplus-saas-provider.json
108141
kubectl get resourcecompositions
109142
kubectl describe resourcecomposition wordpress-service-composition
110-
until kubectl get pods -n wp-tenant1 | grep Running; do echo "Waiting for Application Pods to start.."; sleep 1; done
143+
144+
- name: Wait for Application Pods to Start
145+
run: |
146+
until kubectl get pods -n wp-tenant1 | grep Running; do
147+
echo "Waiting for Application Pods to start..."
148+
sleep 1
149+
done
150+
151+
- name: Interact with Deployed Application
152+
run: |
111153
kubectl appresources WordpressService wp-tenant1 –k kubeplus-saas-provider.json
112154
kubectl metrics WordpressService wp-tenant1 $KUBEPLUS_NS -k kubeplus-saas-provider.json
155+
156+
- name: Cleanup Deployed Resources
157+
run: |
113158
kubectl delete wordpressservice wp-tenant1 --kubeconfig=kubeplus-saas-provider.json
114159
kubectl delete resourcecomposition wordpress-service-composition --kubeconfig=kubeplus-saas-provider.json
115-
echo "Running tests..starting in 5 seconds"
116-
sleep 5
160+
161+
- name: Run Unit Tests
162+
run: |
117163
cd tests
118164
python3 -m venv venv
119165
source venv/bin/activate

README.md

Lines changed: 13 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ KubePlus takes an application Helm chart and wraps it under a Kubernetes API (CR
1717
<img src="./docs/kubeplus-with-properties.png" width="700" height="250" class="center">
1818
</p>
1919

20+
## Key Features
21+
2022
### Isolation
2123

2224
KubePlus takes an application Helm chart and wraps it in a Kubernetes API (CRD). This API is used to provision application instances on a cluster. KubePlus isolates each application instance in a separate namespace. It adds a safety perimeter around such namespaces using Kubernetes network policies and non-shared persistent volumes ensuring that each application instance is appropriately isolated from other instances. Additionally, it provides controls for application providers to deploy different tenant application instances on different worker nodes for node isolation.
@@ -37,155 +39,23 @@ A new version of an application can be deployed by updating the application Helm
3739

3840
### Customization
3941

40-
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.
41-
42-
43-
## Demo
44-
45-
https://github.com/cloud-ark/kubeplus/assets/732525/efb255ff-fc73-446b-a583-4b89dbf61638
46-
47-
## Getting Started with an example
48-
49-
Let’s look at an example of creating a multi-instance WordPress Service using KubePlus. The WordPress service provider goes through the following steps towards this on their cluster:
50-
51-
1. Create cluster or use an existing cluster. For testing purposes you can create a [minikube](https://minikube.sigs.k8s.io/docs/) or [kind](https://kind.sigs.k8s.io/) cluster:
52-
53-
`minikube start`
54-
55-
or
56-
57-
`kind create cluster`
58-
59-
2. Unzip KubePlus plugins and set up the PATH
60-
61-
```
62-
wget https://github.com/cloud-ark/kubeplus/raw/master/kubeplus-kubectl-plugins.tar.gz
63-
tar -zxvf kubeplus-kubectl-plugins.tar.gz
64-
export KUBEPLUS_HOME=`pwd`
65-
export PATH=$KUBEPLUS_HOME/plugins:$PATH
66-
kubectl kubeplus commands
67-
```
68-
69-
3. Set the Namespace in which to deploy KubePlus
70-
71-
`export KUBEPLUS_NS=default`
72-
73-
4. Create provider kubeconfig using provider-kubeconfig.py
74-
75-
```
76-
wget https://raw.githubusercontent.com/cloud-ark/kubeplus/master/requirements.txt
77-
wget https://raw.githubusercontent.com/cloud-ark/kubeplus/master/provider-kubeconfig.py
78-
python3 -m venv venv
79-
source venv/bin/activate
80-
pip3 install -r requirements.txt
81-
apiserver=`kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}'`
82-
python3 provider-kubeconfig.py -s $apiserver create $KUBEPLUS_NS
83-
deactivate
84-
```
85-
86-
5. Install KubePlus Operator using the generated provider kubeconfig
87-
88-
```
89-
helm install kubeplus "https://github.com/cloud-ark/operatorcharts/blob/master/kubeplus-chart-4.0.0.tgz?raw=true" --kubeconfig=kubeplus-saas-provider.json -n $KUBEPLUS_NS
90-
until kubectl get pods -A | grep kubeplus | grep Running; do echo "Waiting for KubePlus to start.."; sleep 1; done
91-
```
92-
93-
6. Create Kubernetes CRD representing WordPress Helm chart.
94-
95-
*The WordPress Helm chart can be specified as a [public url](./examples/multitenancy/application-hosting/wordpress/wordpress-service-composition.yaml) or can be [available locally](./examples/multitenancy/application-hosting/wordpress/wordpress-service-composition-localchart.yaml).*
42+
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.
9643

97-
```
98-
kubectl create -f https://raw.githubusercontent.com/cloud-ark/kubeplus/master/examples/multitenancy/application-hosting/wordpress/wordpress-service-composition.yaml --kubeconfig=kubeplus-saas-provider.json
99-
kubectl get resourcecompositions
100-
kubectl describe resourcecomposition wordpress-service-composition
101-
```
102-
103-
If the status of the `wordpress-service-composition` indicates that the new CRD has been created successfully, verify it:
104-
105-
```
106-
kubectl get crds
107-
```
108-
109-
You should see `wordpressservices.platformapi.kubeplus` CRD registered.
44+
## Quick Installation
11045

111-
7. Create WordpressService instance `wp-tenant1`
46+
To install KubePlus and its kubectl plugin, use the following commands:
11247

113-
```
114-
kubectl create -f https://raw.githubusercontent.com/cloud-ark/kubeplus/master/examples/multitenancy/application-hosting/wordpress/tenant1.yaml --kubeconfig=kubeplus-saas-provider.json
115-
```
116-
117-
8. Create WordpressService instance `wp-tenant2`
118-
119-
```
120-
kubectl create -f https://raw.githubusercontent.com/cloud-ark/kubeplus/master/examples/multitenancy/application-hosting/wordpress/tenant2.yaml --kubeconfig=kubeplus-saas-provider.json
121-
```
122-
123-
9. Check created WordpressService instances
124-
125-
```
126-
kubectl get wordpressservices
127-
128-
NAME AGE
129-
wp-tenant1 86s
130-
wp-tenant2 26s
131-
```
132-
133-
10. Check the details of created instance:
134-
135-
```
136-
kubectl describe wordpressservices wp-tenant1
137-
```
138-
139-
11. Check created application resources. Notice that the `WordpressService` instance resources are deployed in a Namespace `wp-tenant1`, which was created by KubePlus.
140-
141-
```
142-
kubectl appresources WordpressService wp-tenant1 –k kubeplus-saas-provider.json
143-
144-
NAMESPACE KIND NAME
145-
default WordpressService wp-tenant1
146-
wp-tenant1 PersistentVolumeClaim mysql-pv-claim
147-
wp-tenant1 PersistentVolumeClaim wp-for-tenant1
148-
wp-tenant1 Service wordpress-mysql
149-
wp-tenant1 Service wp-for-tenant1
150-
wp-tenant1 Deployment mysql
151-
wp-tenant1 Deployment wp-for-tenant1
152-
wp-tenant1 Pod mysql-76d6d9bdfd-2wl2p
153-
wp-tenant1 Pod wp-for-tenant1-87c4c954-s2cct
154-
wp-tenant1 NetworkPolicy allow-external-traffic
155-
wp-tenant1 NetworkPolicy restrict-cross-ns-traffic
156-
wp-tenant1 ResourceQuota wordpressservice-wp-tenant1
157-
```
48+
```sh
49+
wget https://raw.githubusercontent.com/cloud-ark/kubeplus/master/install.sh
50+
chmod +x install.sh
51+
./install.sh --kubeplus --kubeplus-plugin
52+
```
15853

159-
12. Check application resource consumption
160-
161-
```
162-
kubectl metrics WordpressService wp-tenant1 $KUBEPLUS_NS -k kubeplus-saas-provider.json
163-
164-
----------------------------------------------------------
165-
Kubernetes Resources created:
166-
Number of Sub-resources: -
167-
Number of Pods: 2
168-
Number of Containers: 2
169-
Number of Nodes: 1
170-
Number of Not Running Pods: 0
171-
Underlying Physical Resoures consumed:
172-
Total CPU(cores): 0.773497m
173-
Total MEMORY(bytes): 516.30859375Mi
174-
Total Storage(bytes): 40Gi
175-
Total Network bytes received: 0
176-
Total Network bytes transferred: 0
177-
----------------------------------------------------------
178-
```
54+
## Demo
17955

180-
13. Cleanup
56+
https://github.com/cloud-ark/kubeplus/assets/732525/efb255ff-fc73-446b-a583-4b89dbf61638
18157

182-
```
183-
kubectl delete wordpressservice wp-tenant1 --kubeconfig=kubeplus-saas-provider.json
184-
kubectl delete wordpressservice wp-tenant2 --kubeconfig=kubeplus-saas-provider.json
185-
kubectl delete resourcecomposition wordpress-service-composition --kubeconfig=kubeplus-saas-provider.json
186-
helm delete kubeplus -n $KUBEPLUS_NS
187-
python3 provider-kubeconfig.py delete $KUBEPLUS_NS
188-
```
58+
To get started with an example, follow: [kubeplus/examples/getting-started.md](kubeplus/examples/getting-started.md)
18959

19060
<!--
19161
<p align="center">

0 commit comments

Comments
 (0)