-
Notifications
You must be signed in to change notification settings - Fork 316
OpenSDS Installation with Kubernetes Service Catalog
In this tutorial, we will show how OpenSDS provide block storage as a service for Kubernetes users through Service Catalog. Now hope you enjoy the trip!
Please NOTICE that the installation tutorial is tested on Ubuntu 16.04, and we SUGGEST you follow our styles and use Ubuntu 16.04+.
apt-get update && apt-get install -y gcc make libc6-dev
wget https://storage.googleapis.com/golang/go1.12.1.linux-amd64.tar.gz
tar -C /usr/local -zxvf go1.12.1.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile
echo 'export GOPATH=$HOME/gopath' >> /etc/profile
source /etc/profile
wget https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/docker-ce_18.06.1~ce~3-0~ubuntu_amd64.deb
dpkg -i docker-ce_18.06.1~ce~3-0~ubuntu_amd64.deb
kubernetes local cluster
You can startup v1.13.0
k8s local cluster by executing commands blow:
cd $HOME && git clone https://github.com/kubernetes/kubernetes.git
cd $HOME/kubernetes && git checkout v1.13.0
make
echo alias kubectl='$HOME/kubernetes/cluster/kubectl.sh' >> /etc/profile
hack/install-etcd.sh
ENABLE_DAEMON=true ALLOW_PRIVILEGED=true RUNTIME_CONFIG="settings.k8s.io/v1alpha1=true" LOG_LEVEL=5 hack/local-up-cluster.sh -O
To avoid some errors, please make sure your helm version is more than v2.7.0:
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh
chmod +x get_helm.sh && ./get_helm.sh
helm init
kubectl get po -n kube-system # check if the till-deploy pod is running
Tiller is the in-cluster server component of Helm. By default,
helm init
installs the Tiller pod into the kube-system
namespace,
and configures Tiller to use the default
service account.
Tiller will need to be configured with cluster-admin
access to properly install
Service Catalog:
kubectl create clusterrolebinding tiller-cluster-admin \
--clusterrole=cluster-admin \
--serviceaccount=kube-system:default
Service Catalog is easily installed via a Helm chart.
This chart is located in a chart repository just for Service Catalog. Add this repository to your local machine:
helm repo add svc-cat https://svc-catalog-charts.storage.googleapis.com
Then, ensure that the repository was successfully added:
helm search service-catalog
You should see the following output:
NAME VERSION DESCRIPTION
svc-cat/catalog x,y.z service-catalog API server and controller-manag...
Now that your cluster and Helm are configured properly, installing Service Catalog is simple:
helm install svc-cat/catalog \
--name catalog --namespace catalog
For testing purposes you can deploy OpenSDS local cluster referring to the OpenSDS Cluster Installation through Ansible wiki.
Firstly, please modify the endpoint IP:
wget https://github.com/opensds/opensds-installer/releases/download/v0.5.2/opensds-installer-v0.5.2.tar.gz
tar zxvf opensds-installer-v0.5.2.tar.gz
cd opensds-installer-v0.5.2/charts
vim servicebroker/values.yaml
Replace opensdsEndpoint
with your host ip:
# Please modify opensdsEndpoint field in real environment
opensdsEndpoint: http://207.148.121.48:50040
opensdsAuthStrategy: noauth
Then install it through helm:
helm install servicebroker/ --name service-broker --namespace opensds
kubectl get pod -n opensds
kubectl get clusterservicebrokers,clusterserviceclasses,serviceinstances,servicebindings
- Create service broker
kubectl create -f examples/service-broker.yaml
kubectl get clusterservicebrokers,clusterserviceclasses,clusterserviceplans
- Create service instance
kubectl create -f examples/service-instance.yaml -n opensds
kubectl get serviceinstances -n opensds -o yaml
- Create service instance binding
kubectl create -f examples/service-binding.yaml -n opensds
kubectl get servicebindings -n opensds -o yaml
kubectl describe servicebindings -n opensdss
kubectl get secrets -n opensds
kubectl get secrets service-binding -o yaml -n opensds
kubectl get secrets service-binding -o yaml -n opensds | grep volumeId | awk '{print $2}' | base64 -d && echo
- Create service wordpress for testing
Modify the volume name of podpreset:
vi examples/podpreset-preset.yaml
kubectl create -f examples/podpreset-preset.yaml
kubectl get podpreset
podpreset-preset.yaml
apiVersion: settings.k8s.io/v1alpha1
kind: PodPreset
metadata:
name: allow-database
spec:
selector:
matchLabels:
role: frontend
volumeMounts:
- mountPath: /mnt/wordpress
name: 938b481a-af44-44e4-9cc0-e13ac5c0cc5e
volumes:
- name: 938b481a-af44-44e4-9cc0-e13ac5c0cc5e
flexVolume:
driver: "opensds.io/opensds"
fsType: "ext4"
Then create wordpress.yaml
file:
kubectl create -f examples/wordpress.yaml
socat tcp-listen:8084,reuseaddr,fork tcp:10.0.0.124:8084
wordpress.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: wordpress
spec:
template:
metadata:
labels:
app: wordpress
role: frontend
spec:
containers:
- name: wordpress
image: wordpress:latest
imagePullPolicy: IfNotPresent
ports:
- name: wordpress
containerPort: 8084
---
apiVersion: v1
kind: Service
metadata:
name: wordpress
spec:
type: ClusterIP
ports:
- name: wordpress
port: 8084
targetPort: 8084
protocol: TCP
selector:
app: wordpress
After all things done, you can visit your own blog by searching: http://service_cluster_ip:8084
!
kubectl delete -f examples/podpreset-preset.yaml
kubectl delete -f examples/wordpress.yaml
kubectl delete -n opensds servicebindings service-binding
kubectl delete -n opensds serviceinstances service-instance
kubectl delete clusterservicebrokers service-broker
helm delete --purge service-broker
kubectl delete ns opensds service-broker
helm delete --purge catalog
That's all the tutorial, thank you for watching it!