Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Commit b2ebbe5

Browse files
committed
prototype wip
1 parent ddf4c2e commit b2ebbe5

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

devnotes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ client cert (no CA) :
1111
openssl req -nodes -x509 -sha256 -newkey rsa:4096 -keyout client.key -out client.crt -days 356 -subj "/C=NL/ST=Zuid Holland/L=Rotterdam/O=system:masters/OU=IT Dept/CN=attila"
1212

1313
run etcd:
14-
./etcd --listen-client-urls=http://0.0.0.0:2379 --advertise-client-urls=http://0.0.0.0:2379
14+
./etcd --listen-client-urls=http://0.0.0.0:2379 --advertise-client-urls=http://0.0.0.0:2379 --wal-dir=/home/csviri/.jenvtest/etcddata/ --unsafe-no-fsync=true
1515

1616
run self signed:
1717

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@
7272
<version>${assertj.version}</version>
7373
<scope>test</scope>
7474
</dependency>
75+
<dependency>
76+
<groupId>commons-io</groupId>
77+
<artifactId>commons-io</artifactId>
78+
<version>2.11.0</version>
79+
</dependency>
7580
</dependencies>
7681

7782

src/main/java/com/csviri/kubeapi/APIServer.java

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.csviri.kubeapi;
22

3+
import org.apache.commons.io.FileUtils;
34
import org.slf4j.Logger;
45
import org.slf4j.LoggerFactory;
56

@@ -31,7 +32,7 @@ public APIServer(APIServerConfig config) {
3132
public void start() {
3233
log.debug("Stating. Using jenvtest dir: {}", config.getJenvtestDirectory());
3334
prepareLogDirectory();
34-
cleanPreviousState();
35+
cleanEtcdData();
3536
startEtcd();
3637
startApiServer();
3738
kubeConfigManager.updateKubeConfig();
@@ -52,6 +53,7 @@ public void stop() {
5253
stopApiServer();
5354
stopEtcd();
5455
kubeConfigManager.cleanupFromKubeConfig();
56+
cleanEtcdData();
5557
}
5658

5759
private void stopApiServer() {
@@ -61,8 +63,12 @@ private void stopApiServer() {
6163
log.debug("API Server stopped");
6264
}
6365

64-
private void cleanPreviousState() {
65-
// todo
66+
private void cleanEtcdData() {
67+
try {
68+
FileUtils.deleteDirectory(new File("default.etcd"));
69+
} catch (IOException e) {
70+
throw new KubeApiException(e);
71+
}
6672
}
6773

6874

@@ -74,7 +80,7 @@ private void stopEtcd() {
7480
}
7581

7682
private void waitUntilDefaultNamespaceCreated() {
77-
83+
// todo
7884
}
7985

8086
// todo detect if process not started up correctly
@@ -108,19 +114,24 @@ private void startApiServer() {
108114
}
109115
var logsFile = new File(config.logDirectory(), "apiserver.logs");
110116
apiServerProcess = new ProcessBuilder(apiServerBinary.getAbsolutePath(),
111-
"--cert-dir", config.getJenvtestDirectory(), "--etcd-servers",
112-
"http://0.0.0.0:2379", "--authorization-mode", "RBAC", "--service-account-issuer",
113-
"https://localhost", "--service-account-signing-key-file", certManager.getAPIServerKeyPath(),
117+
"--cert-dir", config.getJenvtestDirectory(),
118+
"--etcd-servers", "http://0.0.0.0:2379",
119+
"--authorization-mode", "RBAC",
120+
"--service-account-issuer", "https://localhost",
121+
"--service-account-signing-key-file", certManager.getAPIServerKeyPath(),
114122
"--service-account-signing-key-file", certManager.getAPIServerKeyPath(),
115-
"--service-account-key-file", certManager.getAPIServerKeyPath(), "--service-account-issuer",
116-
certManager.getAPIServerCertPath(),
117-
"--disable-admission-plugins", "ServiceAccount", "--client-ca-file", certManager.getClientCertPath()
118-
// "--service-cluster-ip-range", "10.0.0.0/24",
119-
// "--allow-privileged", "true"
123+
"--service-account-key-file", certManager.getAPIServerKeyPath(),
124+
"--service-account-issuer", certManager.getAPIServerCertPath(),
125+
"--disable-admission-plugins", "ServiceAccount",
126+
"--client-ca-file", certManager.getClientCertPath(),
127+
"--service-cluster-ip-range", "10.0.0.0/24",
128+
"--allow-privileged"
120129
)
121130
.redirectOutput(logsFile)
122131
.redirectError(logsFile)
123132
.start();
133+
// todo detect premature termination
134+
// apiServerProcess.onExit()
124135
log.debug("API Server started");
125136
} catch (IOException e) {
126137
throw new RuntimeException(e);

0 commit comments

Comments
 (0)