Skip to content

[Kubernetes] Make HA master setup compatible with SONiC buildimage join process#2306

Merged
isabelmsft merged 6 commits intosonic-net:masterfrom
isabelmsft:modify_ha_master
Oct 28, 2020
Merged

[Kubernetes] Make HA master setup compatible with SONiC buildimage join process#2306
isabelmsft merged 6 commits intosonic-net:masterfrom
isabelmsft:modify_ha_master

Conversation

@isabelmsft
Copy link
Copy Markdown
Contributor

@isabelmsft isabelmsft commented Oct 4, 2020

Description of PR

Summary:
Make HA master setup compatible with automated SONiC buildimage join process

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Approach

What is the motivation for this PR?

The current SONiC buildimage assumes the Kubernetes conf file is available at HTTP server on master; this conf file is used to join the SONiC worker node to the Kubernetes master. Previously, the HA testbed master expected SONiC worker nodes to join manually via a command output during master initialization. This PR allows automated join of the SONiC DUT to the HA Kubernetes master by downloading the necessary conf file from a new HTTP server hosted at the master VIP.

How did you do it?

  • Host Apache server on HAProxy node, as the SONiC worker node communicates with the VIP (IP of HAProxy node)
  • Set up necessary firewall and SSL certs
  • Copy conf file from Kubernetes master to HAProxy node and enable download
  • Change HAProxy node to be listening on port 6443 (to be compatible with port_check in SONiC buildimage)

How did you verify/test it?

  • Created HA master on testbed server via testbed-cli.sh script
  • Joined SONiC DUT automatically by configuring master server VIP via sudo config kube server ip <HAPROXY NODE IP/VIP>
  • show kube server on SONiC DUT shows master is connected
  • kubectl get nodes on master shows all 3 master nodes and SONiC DUT

@isabelmsft isabelmsft changed the title [Kubernetes] Make HA testbed K8s master compatible with kube-systemd feature buildimage changes [Kubernetes] Make HA master setup compatible with SONiC buildimage join process Oct 4, 2020
@isabelmsft isabelmsft requested a review from qiluo-msft October 12, 2020 20:47
become: yes
fetch:
src: /etc/kubernetes/admin.conf
dest: /tmp/helper/admin.conf
Copy link
Copy Markdown
Contributor

@qiluo-msft qiluo-msft Oct 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/tmp/helper/ [](start = 10, length = 12)

Why not set dest to /var/www/html directly? #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This saves the file to host server so that the file can be transferred from one VM to another VM. init_master_leader.yml is running on Master1 VM, but I need the file on the HAProxy VM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then you may remove this fetch completely, and use below copy with src as /etc/kubernetes/admin.conf ?


In reply to: 508867244 [](ancestors = 508867244)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I get this error:
"Could not find or access '/etc/kubernetes/admin.conf' on the Ansible Controller. When I wrote the original code I also thought there would be a more straightforward way to copy the file from one VM to another, but using the /tmp directory was the only way I tried that worked for me

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand now. Please give correct comments, especially on the src/dest machines.


In reply to: 508884204 [](ancestors = 508884204,508867244)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, I get that error because the /etc/kubernetes/admin.conf is on the server, not on the VM.
For fetch module:

  • src is the master VM, on which /etc/kubernetes/admin.conf is present
  • dest is the server

For copy module:

  • src is the server
  • dest is the HAProxy VM

copy:
src: /tmp/helper/admin.conf
dest: /var/www/html/admin.conf
mode: '777'
Copy link
Copy Markdown
Contributor

@qiluo-msft qiluo-msft Oct 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

777 [](start = 11, length = 3)

Everyone can write or del it, is it safe? #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed to 755 permissions. This was the most restrictive I could make it while ensuring that the SONiC DUT could still download the file properly. This is also in-line with the response here https://askubuntu.com/questions/451922/apache-access-denied-because-search-permissions-are-missing

file:
path: "/var/www/html"
state: directory
mode: '777'
Copy link
Copy Markdown
Contributor

@qiluo-msft qiluo-msft Oct 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

777 [](start = 11, length = 3)

Is it too broad permission? #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed to 755 permissions. This was the most restrictive I could make it while ensuring that the SONiC DUT could still download the file properly. This is also in-line with the response here https://askubuntu.com/questions/451922/apache-access-denied-because-search-permissions-are-missing

src: "default-ssl.conf.j2"
dest: "/etc/apache2/sites-available/default-ssl.conf"

- name: Enable Apaache SSL
Copy link
Copy Markdown
Contributor

@qiluo-msft qiluo-msft Oct 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apaache [](start = 15, length = 7)

typo? #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fixed :)


- name: Initializing Kubernetes cluster
shell: kubeadm init --control-plane-endpoint {{ haproxy_ip }}:80 --upload-certs --apiserver-advertise-address {{ ansible_ens2.ipv4.address }} --skip-phases=addon/kube-proxy --skip-phases=addon/coredns --ignore-preflight-errors=NumCPU
shell: kubeadm init --control-plane-endpoint {{ haproxy_ip }}:{{ k8s_port }} --upload-certs --apiserver-advertise-address {{ ansible_ens2.ipv4.address }} --skip-phases=addon/kube-proxy --skip-phases=addon/coredns
Copy link
Copy Markdown
Contributor

@qiluo-msft qiluo-msft Oct 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beadm init --control-plane-endpoint {{ haproxy_ip }}:{{ k8 [](start = 11, length = 58)

This line is too long to read. Could you split? #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I split it

Copy link
Copy Markdown
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As comments

@isabelmsft
Copy link
Copy Markdown
Contributor Author

retest vsimage please

@isabelmsft isabelmsft merged commit 725a50c into sonic-net:master Oct 28, 2020
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
Including change:

* 7ff8f75 2022-06-03 | Revert "[portsorch]: Prevent LAG member configuration when port has active ACL binding (sonic-net#2165)" (sonic-net#2306) (HEAD -> 202205, github/202205) [bingwang-ms]

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants