#!/bin/bash # Copyright 2017 AT&T Intellectual Property, Inc # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # #. What this is: script to setup a Ceph-based SDS (Software Defined Storage) #. service for a kubernetes cluster, using Helm as deployment tool. #. Prerequisites: #. - Ubuntu xenial server for master and agent nodes #. - key-based auth setup for ssh/scp between master and agent nodes #. - 192.168.0.0/16 should not be used on your server network interface subnets #. Usage: # Intended to be called from k8s-cluster.sh in this folder. To run directly: #. $ bash ceph-helm.sh "" [ceph_dev] #. nodes: space-separated list of ceph node IPs #. cluster-net: CIDR of ceph cluster network e.g. 10.0.0.1/24 #. public-net: CIDR of public network #. ceph_dev: disk to use for ceph. ***MUST NOT BE USED FOR ANY OTHER PURPOSE*** #. if not provided, ceph data will be stored on osd nodes in /ceph #. #. Status: work in progress, incomplete # function log() { f=$(caller 0 | awk '{print $2}') l=$(caller 0 | awk '{print $1}') echo "$f:$l ($(date)) $1" } function make_ceph_setup() { tee ~/ceph_setup.sh <<'EOG' #!/bin/bash # Basic server pre-reqs dist=$(grep --m 1 ID /etc/os-release | awk -F '=' '{print $2}' | sed 's/"//g') if [[ "$dist" == "ubuntu" ]]; then sudo apt-get install -y ceph ceph-common else # per http://docs.ceph.com/docs/master/install/get-packages/ sudo tee /etc/yum.repos.d/ceph.repo <<'EOF' [ceph] name=Ceph packages for $basearch baseurl=https://download.ceph.com/rpm-luminous/el7/x86_64 enabled=1 priority=2 gpgcheck=1 gpgkey=https://download.ceph.com/keys/release.asc [ceph-noarch] name=Ceph noarch packages baseurl=https://download.ceph.com/rpm-luminous/el7/noarch enabled=1 priority=2 gpgcheck=1 gpgkey=https://download.ceph.com/keys/release.asc [ceph-source] name=Ceph source packages baseurl=https://download.ceph.com/rpm-luminous/el7/SRPMS enabled=0 priority=2 gpgcheck=1 gpgkey=https://download.ceph.com/keys/release.asc EOF # TODO: find out why package us unsigned and thus need --nogpgcheck sudo rpm --import 'https://download.ceph.com/keys/release.asc' sudo yum install --nogpgcheck -y ceph ceph-common fi EOG } function setup_ceph() { nodes=$1 private_net=$2 public_net=$3 dev=$4 log "Install ceph and ceph-common" make_ceph_setup bash ~/ceph_setup.sh # per https://github.com/att/netarbiter/tree/master/sds/ceph-docker/examples/helm log "Clone netarbiter" git clone https://github.com/att/netarbiter.git if [[ "$dist" != "ubuntu" ]]; then log "Update ceph-helm chart to point to centos images" sed -i -- 's~daemon: docker.io/knowpd~#daemon: docker.io/knowpd~' \ netarbiter/sds/ceph-docker/examples/helm/ceph/values.yaml sed -i -- 's~#daemon: docker.io/ceph~daemon: docker.io/ceph~' \ netarbiter/sds/ceph-docker/examples/helm/ceph/values.yaml sed -i -- 's~ceph_init: docker.io/knowpd~#ceph_init: docker.io/knowpd~' \ netarbiter/sds/ceph-docker/examples/helm/ceph/values.yaml sed -i -- 's~#ceph_init: docker.io/kollakube~ceph_init: docker.io/kollakube~' \ netarbiter/sds/ceph-docker/examples/helm/ceph/values.yaml fi log "Prepare a ceph namespace in your K8s cluster" cd netarbiter/sds/ceph-docker/examples/helm ./prep-ceph-ns.sh log "Run ceph-mon, ceph-mgr, ceph-mon-check, and rbd-provisioner" # Pre-req per https://github.com/att/netarbiter/tree/master/sds/ceph-docker/examples/helm#notes kubedns=$(kubectl get service -o json --namespace kube-system kube-dns | \ jq -r '.spec.clusterIP') cat <