mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
update the KubernetesSeedProvider.java to v1beta3
This commit is contained in:
parent
de0d59be05
commit
9dc901735a
@ -24,7 +24,7 @@ spec:
|
|||||||
value: 512M
|
value: 512M
|
||||||
- name: HEAP_NEWSIZE
|
- name: HEAP_NEWSIZE
|
||||||
value: 100M
|
value: 100M
|
||||||
image: "kubernetes/cassandra:v2"
|
image: gcr.io/google_containers/cassandra:v3
|
||||||
name: cassandra
|
name: cassandra
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 9042
|
- containerPort: 9042
|
||||||
|
@ -11,7 +11,7 @@ spec:
|
|||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: "1"
|
cpu: "1"
|
||||||
image: kubernetes/cassandra:v2
|
image: gcr.io/google_containers/cassandra:v3
|
||||||
name: cassandra
|
name: cassandra
|
||||||
ports:
|
ports:
|
||||||
- name: cql
|
- name: cql
|
||||||
|
Binary file not shown.
@ -5,6 +5,16 @@
|
|||||||
<version>0.0.2</version>
|
<version>0.0.2</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>2.3.2</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.7</source>
|
||||||
|
<target>1.7</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -21,9 +21,20 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class KubernetesSeedProvider implements SeedProvider {
|
public class KubernetesSeedProvider implements SeedProvider {
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
static class Address {
|
||||||
|
public String IP;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
static class Subset {
|
||||||
|
public List<Address> addresses;
|
||||||
|
}
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
static class Endpoints {
|
static class Endpoints {
|
||||||
public String[] endpoints;
|
public List<Subset> subsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getEnvOrDefault(String var, String def) {
|
private static String getEnvOrDefault(String var, String def) {
|
||||||
@ -64,17 +75,18 @@ public class KubernetesSeedProvider implements SeedProvider {
|
|||||||
|
|
||||||
String host = protocol + "://" + hostName + ":" + hostPort;
|
String host = protocol + "://" + hostName + ":" + hostPort;
|
||||||
String serviceName = getEnvOrDefault("CASSANDRA_SERVICE", "cassandra");
|
String serviceName = getEnvOrDefault("CASSANDRA_SERVICE", "cassandra");
|
||||||
String path = "/api/v1beta3/endpoints/";
|
String path = "/api/v1beta3/namespaces/default/endpoints/";
|
||||||
try {
|
try {
|
||||||
URL url = new URL(host + path + serviceName);
|
URL url = new URL(host + path + serviceName);
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
Endpoints endpoints = mapper.readValue(url, Endpoints.class);
|
Endpoints endpoints = mapper.readValue(url, Endpoints.class);
|
||||||
if (endpoints != null) {
|
if (endpoints != null) {
|
||||||
// Here is a problem point, endpoints.endpoints can be null in first node cases.
|
// Here is a problem point, endpoints.subsets can be null in first node cases.
|
||||||
if (endpoints.endpoints != null){
|
if (endpoints.subsets != null && !endpoints.subsets.isEmpty()){
|
||||||
for (String endpoint : endpoints.endpoints) {
|
for (Subset subset : endpoints.subsets) {
|
||||||
String[] parts = endpoint.split(":");
|
for (Address address : subset.addresses) {
|
||||||
list.add(InetAddress.getByName(parts[0]));
|
list.add(InetAddress.getByName(address.IP));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user