mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
A more robust improvement on the cassandra example. The Kubernetes API server can be set in the pod template or by grabbing the environment variable. Nick Sabine <nsabine@redhat.com> generated this improvement.
This commit is contained in:
parent
1b841d26e7
commit
3a4d2d61e2
Binary file not shown.
@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>io.k8s.cassandra</groupId>
|
<groupId>io.k8s.cassandra</groupId>
|
||||||
<artifactId>kubernetes-cassandra</artifactId>
|
<artifactId>kubernetes-cassandra</artifactId>
|
||||||
<version>0.0.4</version>
|
<version>0.0.5</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -100,7 +100,10 @@ public class KubernetesSeedProvider implements SeedProvider {
|
|||||||
|
|
||||||
public List<InetAddress> getSeeds() {
|
public List<InetAddress> getSeeds() {
|
||||||
List<InetAddress> list = new ArrayList<InetAddress>();
|
List<InetAddress> list = new ArrayList<InetAddress>();
|
||||||
String host = getEnvOrDefault("KUBERNETES_API_HOST","https://kubernetes.default.svc.cluster.local");
|
//String host = "https://kubernetes.default.svc.cluster.local";
|
||||||
|
String proto = "https://";
|
||||||
|
String host = getEnvOrDefault("KUBERNETES_PORT_443_TCP_ADDR", "kubernetes.default.svc.cluster.local");
|
||||||
|
String port = getEnvOrDefault("KUBERNETES_PORT_443_TCP_PORT", "443");
|
||||||
String serviceName = getEnvOrDefault("CASSANDRA_SERVICE", "cassandra");
|
String serviceName = getEnvOrDefault("CASSANDRA_SERVICE", "cassandra");
|
||||||
String podNamespace = getEnvOrDefault("POD_NAMESPACE", "default");
|
String podNamespace = getEnvOrDefault("POD_NAMESPACE", "default");
|
||||||
String path = String.format("/api/v1/namespaces/%s/endpoints/", podNamespace);
|
String path = String.format("/api/v1/namespaces/%s/endpoints/", podNamespace);
|
||||||
@ -110,7 +113,7 @@ public class KubernetesSeedProvider implements SeedProvider {
|
|||||||
SSLContext ctx = SSLContext.getInstance("SSL");
|
SSLContext ctx = SSLContext.getInstance("SSL");
|
||||||
ctx.init(null, trustAll, new SecureRandom());
|
ctx.init(null, trustAll, new SecureRandom());
|
||||||
|
|
||||||
URL url = new URL(host + path + serviceName);
|
URL url = new URL(proto + host + ":" + port + path + serviceName);
|
||||||
logger.info("Getting endpoints from " + url);
|
logger.info("Getting endpoints from " + url);
|
||||||
HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
|
HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user