You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2015/05/28 12:09:10 UTC
stratos git commit: Adding minions public IP addresses to Kubernetes
service access URLs exposed by the UI
Repository: stratos
Updated Branches:
refs/heads/master b00dd2d29 -> c24d35aa1
Adding minions public IP addresses to Kubernetes service access URLs exposed by the UI
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/c24d35aa
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/c24d35aa
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/c24d35aa
Branch: refs/heads/master
Commit: c24d35aa103d787bfb75eb3e1e284baa45e44bf0
Parents: b00dd2d
Author: Imesh Gunaratne <im...@apache.org>
Authored: Thu May 28 15:38:43 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Thu May 28 15:38:43 2015 +0530
----------------------------------------------------------------------
.../controller/iaases/kubernetes/KubernetesIaas.java | 11 ++++++++---
samples/cartridges/kubernetes/php.json | 6 +++++-
2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/c24d35aa/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
index 6a90c73..4dfa38f 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
@@ -477,6 +477,7 @@ public class KubernetesIaas extends Iaas {
// Prepare minion public IP addresses
List<String> minionPrivateIPList = new ArrayList<String>();
+ List<String> minionPublicIPList = new ArrayList<String>();
KubernetesHost[] kubernetesHosts = kubernetesCluster.getKubernetesHosts();
if ((kubernetesHosts == null) || (kubernetesHosts.length == 0) || (kubernetesHosts[0] == null)) {
throw new RuntimeException("Hosts not found in kubernetes cluster: [cluster] "
@@ -485,6 +486,7 @@ public class KubernetesIaas extends Iaas {
for (KubernetesHost host : kubernetesHosts) {
if (host != null) {
minionPrivateIPList.add(host.getPrivateIPAddress());
+ minionPublicIPList.add(host.getPublicIPAddress());
}
}
if (log.isDebugEnabled()) {
@@ -518,9 +520,10 @@ public class KubernetesIaas extends Iaas {
String containerPortName = KubernetesIaasUtil.preparePortNameFromPortMapping(portMapping);
try {
- String[] publicIPs = minionPrivateIPList.toArray(new String[minionPrivateIPList.size()]);
+ // Services need to use minions private IP addresses for creating iptable rules
+ String[] minionPrivateIPArray = minionPrivateIPList.toArray(new String[minionPrivateIPList.size()]);
kubernetesApi.createService(serviceId, serviceLabel, servicePort, containerPortName,
- publicIPs, sessionAffinity);
+ minionPrivateIPArray, sessionAffinity);
} finally {
// Persist kubernetes service sequence no
CloudControllerContext.getInstance().persist();
@@ -536,7 +539,9 @@ public class KubernetesIaas extends Iaas {
KubernetesService kubernetesService = new KubernetesService();
kubernetesService.setId(service.getId());
kubernetesService.setPortalIP(service.getPortalIP());
- kubernetesService.setPublicIPs(service.getPublicIPs());
+ // Expose minions public IP addresses as they need to be accessed by external networks
+ String[] minionPublicIPArray = minionPublicIPList.toArray(new String[minionPublicIPList.size()]);
+ kubernetesService.setPublicIPs(minionPublicIPArray);
kubernetesService.setProtocol(portMapping.getProtocol());
kubernetesService.setPort(service.getPort());
kubernetesService.setContainerPort(containerPort);
http://git-wip-us.apache.org/repos/asf/stratos/blob/c24d35aa/samples/cartridges/kubernetes/php.json
----------------------------------------------------------------------
diff --git a/samples/cartridges/kubernetes/php.json b/samples/cartridges/kubernetes/php.json
index f14ac1b..007f70d 100755
--- a/samples/cartridges/kubernetes/php.json
+++ b/samples/cartridges/kubernetes/php.json
@@ -21,7 +21,7 @@
"iaasProvider": [
{
"type": "kubernetes",
- "imageId": "stratos/php:4.1.0-beta",
+ "imageId": "stratos/php:4.1.0",
"networkInterfaces": [
],
"property": [
@@ -36,6 +36,10 @@
{
"name": "KUBERNETES_CONTAINER_MEMORY",
"value": "0"
+ },
+ {
+ "name": "KUBERNETES_SERVICE_SESSION_AFFINITY",
+ "value": "ClientIP"
}
]
}