第29节 Feat/support nvidia docker and nonroot #2048


❤️💕💕记录sealosopen in new window开源项目的学习过程。k8s,docker和云原生的学习open in new window。Myblog:http://nsddd.topopen in new window


[TOC]

Proposal

  • https://github.com/sealerio/sealer/pull/2048/

This PR support two feature:

  1. Detect nvidia gpu, if exist, should force use docker sock for kubelet
  2. Support install cluster using non root sudoer.

Resolved Issue:

Learn GitHub modify someone else's pull request and commit

Sometimes we need to make some changes to the pull request that community developers submit to our project, such as some configuration files and resource files. In this case we can respond directly to the request to make the change, but instead we can use a simpler solution: we can directly commit to the pull request.

I'll take this warehouse as an example~

As a classic example, this pr and tutorial is very helpful in regulating the development process.

**First, **Find the pull request branch name that needs to be modified:

  • VinceCui:feat/support-nvidia-docker-and-nonroot

image-20230218181350175

Add remote repository

**First you need to add the pull request author's repository locally as another remote repository: **

  • https://github.com/VinceCui/sealer/tree/feat/support-nvidia-docker-and-nonroot

image-20230218183733938

$ git remote set-url VinceCui https://ghproxy.com/https://github.com/VinceCui/sealer/

**Synchronize warehouse and update remote warehouse content: **

$ git fetch VinceCui feat/support-nvidia-docker-and-nonroot

**After the synchronization is complete, we need to switch to the branch from which the other party initiated the pull request, which is the branch from which we want to commit the new commit: **

$ git checkout -b VinceCui VinceCui/feat/support-nvidia-docker-and-nonroot

**Submitted and modified: **

After switching to VinceCui/feat branch, the file changes can be made, and the commit process is the same as usual:

$ git commit -a -s -m "feat: something"

Once you've made sure the changes are complete and committed, push them to the other repository. Pay attention to the push target branch here, git may prompt inconsistent branch name, just push as prompted:

git push VinceCui HEAD:main

Once the push is complete, you should be able to see the change on the GitHub pull request page.

PR Site Solutions

关于 PR 信息:

// InfraDriver treat the entire cluster as an operating system kernel,
// interface function here is the target system call.
type InfraDriver interface {
        // CmdAsync exec command on remote host, and asynchronous return logs
-        CmdAsync(host net.IP, cmd ...string) error
+        CmdAsync(host net.IP, env map[string]interface{}, cmd ...string) error
        // Cmd exec command on remote host, and return combined standard output and standard error
-        Cmd(host net.IP, cmd string) ([]byte, error)
+        Cmd(host net.IP, env map[string]interface{}, cmd string) ([]byte, error)
        // CmdToString exec command on remote host, and return spilt standard output and standard error
-        CmdToString(host net.IP, cmd, spilt string) (string, error)
+        CmdToString(host net.IP, env map[string]interface{}, cmd, spilt string) (string, error)
}

resolve

Resolved issue: #1491open in new window#1999open in new window

Resolved remote read permission to sshd_config file:

$ ls -al /etc/ssh/sshd_config
-rw------- 1 root root 3797 Feb 15 16:35 /etc/ssh/sshd_config
$ sudo chmod 644 /etc/ssh/sshd_config

existing problem

  • Still needs to assign non-secret permissions to user sudo(Every node except master0):
# echo "sealer ALL=(ALL) NOPASSWD: NOPASSWD: ALL" >> /etc/sudoers