Skip to content

Commit

Permalink
fixing kuberenetes slave and master circle dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
eskimo committed Oct 3, 2022
1 parent a964314 commit c3593b1
Show file tree
Hide file tree
Showing 16 changed files with 142 additions and 188 deletions.
136 changes: 0 additions & 136 deletions services_setup/kube-master/setup-kubectl-master.sh

This file was deleted.

3 changes: 0 additions & 3 deletions services_setup/kube-master/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ fail_if_error $? /dev/null 301
bash ./setup-kubectl.sh
fail_if_error $? /dev/null 302

bash ./setup-kubectl-master.sh
fail_if_error $? /dev/null 303

bash /etc/k8s/runtime_config/setup-runtime-kubectl.sh
fail_if_error $? /dev/null 304

Expand Down
70 changes: 68 additions & 2 deletions services_setup/kube-slave/setup-kubectl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ while [[ -f /etc/k8s/shared/ssl_management_lock ]] ; do
echo " + /etc/k8s/shared/ssl_management_lock exist. waiting 2 secs ... "
sleep 2
let counter=counter+1
if [[ $counter -ge 15 ]]; then
echo " !!! Couldn't get /etc/k8s/shared/ssl_management_lock in 30 seconds. crashing !"
if [[ $counter -ge 30 ]]; then
echo " !!! Couldn't get /etc/k8s/shared/ssl_management_lock in 60 seconds. crashing !"
exit 150
fi
done
Expand All @@ -120,6 +120,7 @@ trap delete_ssl_lock_file EXIT
trap delete_ssl_lock_file ERR



if [[ ! -f /etc/k8s/shared/ssl/ca-config.json ]]; then
echo " + Create and install ca-config.json"
cat > ca-config.json <<EOF
Expand Down Expand Up @@ -309,6 +310,71 @@ EOF
sudo mv clusterrolebinding-default-$USER.yaml /etc/k8s/clusterrolebinding-default-$USER.yaml
fi


if [[ ! -f /etc/k8s/shared/ssl//etc/k8s/shared/ssl/kubernetes-csr.json ]]; then
echo " + Create and install kubernetes-csr.json"
cat > kubernetes-csr.json <<EOF
{
"CN": "kubernetes",
"hosts": [
"127.0.0.1",
"${MASTER_KUBE_MASTER_1}",
"${MASTER_URL}",
"${CLUSTER_KUBERNETES_SVC_IP}",
"kubernetes",
"kubernetes.default",
"kubernetes.default.svc",
"kubernetes.default.svc.cluster",
"kubernetes.default.svc.cluster.local",
"eskimo",
"eskimo.default",
"eskimo.default.svc",
"eskimo.default.svc.cluster",
"eskimo.default.svc.cluster.local",
"eskimo.eskimo",
"eskimo.eskimo.svc",
"eskimo.eskimo.svc.cluster",
"eskimo.eskimo.svc.cluster.local"
],
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "SH",
"ST": "Eskimo",
"L": "Eskimo",
"O": "system:masters",
"OU": "System"
}
]
}
EOF

sudo mv kubernetes-csr.json /etc/k8s/shared/ssl/kubernetes-csr.json
sudo chown kubernetes /etc/k8s/shared/ssl/kubernetes-csr.json
sudo chmod 755 /etc/k8s/shared/ssl/kubernetes-csr.json
fi

if [[ ! -f /etc/k8s/shared/ssl//etc/k8s/shared/ssl/kubernetes.pem ]]; then
# Generate certificates
echo " + (Re-)Generate kubernetes certificates"

sudo /usr/local/bin/cfssl gencert -ca=/etc/k8s/shared/ssl/ca.pem \
-ca-key=/etc/k8s/shared/ssl/ca-key.pem \
-config=/etc/k8s/shared/ssl/ca-config.json \
-profile=kubernetes /etc/k8s/shared/ssl/kubernetes-csr.json | cfssljson -bare kubernetes

echo " + (Re-)Install kubernetes certificates"
sudo mv kubernetes*.pem /etc/k8s/shared/ssl/
sudo chown kubernetes /etc/k8s/shared/ssl/kubernetes*.pem
sudo mv kubernetes*csr* /etc/k8s/shared/ssl/
sudo chown kubernetes /etc/k8s/shared/ssl/kubernetes*csr*
fi



delete_ssl_lock_file

set +e
Expand Down
8 changes: 8 additions & 0 deletions services_setup/zeppelin/inContainerSetupZeppelin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ sudo sed -i -n '1h;1!H;${;g;s/'\
' \"value\": \"python3.7\",'\
'/g;p;}' /usr/local/lib/zeppelin/conf/interpreter.json

sudo sed -i -n '1h;1!H;${;g;s/'\
' \"name\": \"zeppelin.spark.enableSupportedVersionCheck\",\n'\
' \"value\": true,'\
'/'\
' \"name\": \"zeppelin.spark.enableSupportedVersionCheck\",\n'\
' \"value\": false,'\
'/g;p;}' /usr/local/lib/zeppelin/conf/interpreter.json


echo " - Configuring ElasticSearch interpreter"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public class Dependency {
@Getter @Setter
private boolean restart = true; // default is true

@Getter @Setter
private boolean dependentInstalledFirst = false; // false by default

private String conditional = null;

public boolean isMandatory(ConfigurationOwner wrapper) {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/ch/niceideas/eskimo/model/service/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ public List<EditableSettings> getEditableSettings() {

public int getRelevantDependenciesCount() {
return (int) dependencies.stream()
.filter(dep -> !dep.getMasterService().equals(getName()) && !dep.getMasterService().equals(NodesConfigWrapper.NODE_ID_FIELD))
.filter(dep ->
!dep.getMasterService().equals(getName())
&& !dep.getMasterService().equals(NodesConfigWrapper.NODE_ID_FIELD)
&& !dep.isDependentInstalledFirst()
)
.count();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ public void afterPropertiesSet() throws Exception {
Boolean depRestart = depObj.has("restart") ? depObj.getBoolean("restart") : null;
dependency.setRestart(depRestart == null || depRestart);

Boolean dependentInstalledFirst = depObj.has("dependentInstalledFirst") ? depObj.getBoolean("dependentInstalledFirst") : null;
dependency.setDependentInstalledFirst(dependentInstalledFirst != null && dependentInstalledFirst); // false by default

String conditionalDependency = depObj.has("conditional") ? depObj.getString("conditional") : null;
if (StringUtils.isNotBlank(conditionalDependency)) {
dependency.setConditional (conditionalDependency);
Expand Down Expand Up @@ -739,12 +742,12 @@ public int compareServices(Service one, Service other) {

// need to browse dependencies
for (Dependency dep : one.getDependencies()) {
if (dep.getMasterService().equals(other.getName())) {
if (dep.getMasterService().equals(other.getName()) && !dep.isDependentInstalledFirst()) {
return 1;
}
}
for (Dependency dep : other.getDependencies()) {
if (dep.getMasterService().equals(one.getName())) {
if (dep.getMasterService().equals(one.getName()) && !dep.isDependentInstalledFirst()) {
return -1;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public <T extends OperationId> List<List<T>> orderOperations (
operationForService.add(operation);
}

// 2. Order by depencencies
// 2. Order by dependencies
List<Service> services = groupedOperations.keySet().stream()
.sorted((one, other) -> servicesDefinition.compareServices(one, other))
.map(service -> servicesDefinition.getService(service))
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/services.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@
"masterService": "kube-slave",
"numberOfMasters": 1,
"mandatory": true,
"restart": false
"restart": false,
"dependentInstalledFirst": true
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ public NodesConfigWrapper resolveRanges(NodesConfigWrapper rawNodesConfig) throw
assertEquals ("{\n" +
" \"command\": {\n" +
" \"restarts\": [\n" +
" {\"kube-master\": \"192.168.10.11\"},\n" +
" {\"kube-slave\": \"192.168.10.11\"},\n" +
" {\"kube-slave\": \"192.168.10.13\"},\n" +
" {\"kube-master\": \"192.168.10.11\"},\n" +
" {\"spark-console\": \"(kubernetes)\"},\n" +
" {\"logstash\": \"(kubernetes)\"},\n" +
" {\"zeppelin\": \"(kubernetes)\"}\n" +
Expand Down
Loading

0 comments on commit c3593b1

Please sign in to comment.