Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
byrnedo committed Jul 11, 2024
1 parent 557e84b commit 6a616c3
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 134 deletions.
8 changes: 4 additions & 4 deletions hack/test-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
labels:
app: nginx
spec:
replicas: 0
replicas: 1
selector:
matchLabels:
app: nginx
Expand All @@ -18,8 +18,8 @@ spec:
app: nginx
spec:
containers:
- name: nginx
- name: nginx1
image: nginx:1.14.2
- name: nginx2
image: nginx:1.14.2
# ports:
# - containerPort: 8000
---
12 changes: 6 additions & 6 deletions manifests/coredns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ spec:
spec:
hostNetwork: true
volumes:
- name: skate
- name: cni
hostPath:
path: /etc/skate
path: /var/lib/skatelet/cni/podman
containers:
- name: coredns
image: ghcr.io/skateco/coredns
volumeMounts:
- mountPath: /etc/skate
name: skate
- mountPath: /var/lib/skatelet/cni/podman
name: cni
env:
- name: CORE_FILE
value: |
cluster.skate:5553 {
bind lo 0.0.0.0
hosts /run/containers/cni/dnsname/podman/addnhosts
hosts /var/lib/skatelet/cni/podman/addnhosts
}
cluster.skate:53 {
Expand All @@ -45,7 +45,7 @@ spec:
loadbalance round_robin
}
. {
.:53 {
bind lo 0.0.0.0
forward . 8.8.8.8
cache
Expand Down
24 changes: 21 additions & 3 deletions src/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,16 @@ async fn create_node(args: CreateNodeArgs) -> Result<(), Box<dyn Error>> {
}

async fn setup_networking(conn: &SshClient, cluster_conf: &Cluster, node: &Node, _info: &NodeSystemInfo, args: &CreateNodeArgs) -> Result<(), Box<dyn Error>> {
let cmd = "sqlite3 -version || sudo apt-get install -y sqlite3";
conn.execute(cmd).await?;

let cmd = "sudo cp /usr/share/containers/containers.conf /etc/containers/containers.conf";
conn.execute(cmd).await?;

let cmd = format!("sudo sed -i 's&#default_subnet[ =].*&default_subnet = \"{}\"&' /etc/containers/containers.conf", node.subnet_cidr);
conn.execute(&cmd).await?;
let cmd = "sudo sed -i 's&#network_backend[ =].*&network_backend = \"cni\"&' /etc/containers/containers.conf";
conn.execute(&cmd).await?;

let cmd = "sudo ip link del cni-podman0|| exit 0";
conn.execute(&cmd).await?;
Expand Down Expand Up @@ -243,10 +248,18 @@ async fn setup_networking(conn: &SshClient, cluster_conf: &Cluster, node: &Node,

// In ubuntu 24.04 there's an issue with apparmor and podman
// https://bugs.launchpad.net/ubuntu/+source/libpod/+bug/2040483
let cmd = "sudo systemctl disable apparmor.service --now";
conn.execute(cmd).await?;

let cmd = "sudo systemctl list-unit-files apparmor.service";
let apparmor_unit_exists = conn.execute(cmd).await;

if apparmor_unit_exists.is_ok() {
let cmd = "sudo systemctl disable apparmor.service --now";
conn.execute(cmd).await?;
}
let cmd = "sudo aa-teardown";
_ = conn.execute(cmd).await;
let cmd = "sudo apt purge -y apparmor";
_ = conn.execute(cmd).await;


// // install dnsmasq
Expand All @@ -257,12 +270,17 @@ async fn setup_networking(conn: &SshClient, cluster_conf: &Cluster, node: &Node,
conn.execute(cmd).await?;
// changed /etc/resolv.conf to be 127.0.0.1
let cmd = "sudo bash -c 'echo 127.0.0.1 > /etc/resolv.conf'";
conn.execute(cmd).await?;
_ = conn.execute(cmd).await;

/// COREDNS
/// coredns listens on port 53 and 5533
/// port 53 serves .cluster.skate by forwarding to all coredns instances on port 5553
/// uses fanout plugin
// needed for mount
let cmd = "sudo mkdir -p /run/containers/cni";
conn.execute(cmd).await?;

let coredns_yaml_path = "/tmp/skate-coredns.yaml";
let mut file = File::create(coredns_yaml_path)?;
// replace forward list in coredns config with that of other hosts
Expand Down
2 changes: 1 addition & 1 deletion src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Executor for DefaultExecutor {

let file_path = DefaultExecutor::write_to_file(&serde_yaml::to_string(&object)?)?;

let args = ["play", "kube", &file_path, "--start"];
let args = ["play", "kube", &file_path, "--start", "--network=podman" ];
let output = process::Command::new("podman")
.args(args)
.stdin(Stdio::piped())
Expand Down
Loading

0 comments on commit 6a616c3

Please sign in to comment.