-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add k8s master code new #15716
Merged
Merged
Add k8s master code new #15716
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
6d8088a
Add k8s master related code
lixiaoyuner 5b37221
Update
lixiaoyuner 50a2ea6
Get MDM package from buster source repo
lixiaoyuner 46960cf
Remove mdm and mdsd from this change
lixiaoyuner 2cffdc2
Build includes k8s master when k8s file changes
lixiaoyuner 1a9093f
Update
lixiaoyuner 36e440f
Update
lixiaoyuner 9172106
Use current skip pipeline for test
lixiaoyuner a63b74a
Change the branch back in skip step
lixiaoyuner c2fc4f2
Add MDM and MDS container image for k8s master
lixiaoyuner b64c310
Change the branch back in skip step
lixiaoyuner f0663da
Build k8s master image for PR validation
lixiaoyuner be70f19
Fix quotation lack issue
lixiaoyuner 99e1a60
change the target version back
lixiaoyuner 832a0f4
Refine comments and fix grep regex issue
lixiaoyuner 21d2882
Merge branch 'master' into add-k8s-master-code-new
lixiaoyuner 10d6c94
Add one specific service for master entrance
lixiaoyuner c99cb09
Merge branch 'master' into add-k8s-master-code-new
lixiaoyuner 10754fa
Make the script executable
lixiaoyuner 81ea690
Move the master entrance script to /usr/bin
lixiaoyuner 9fb8945
Mount disk by disk path file
lixiaoyuner 3c305e9
Update comments
lixiaoyuner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
files/image_config/kubernetes/kubernetes_master_entrance.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[Unit] | ||
Description=Setup k8s master services | ||
Requires=rc-local.service | ||
After=rc-local.service | ||
Before=sonic.target | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=/usr/bin/kubernetes_master_entrance.sh | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
45 changes: 45 additions & 0 deletions
45
files/image_config/kubernetes/kubernetes_master_entrance.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,47 @@ | ||
#!/bin/bash | ||
|
||
# This script is for kubernetes master image usage | ||
# Will mount kubernetes master disk and execute kubernetes entrance script | ||
|
||
set -x | ||
|
||
# mount disk from host | ||
mount_point="/from_host" | ||
disk_by_path_dir="/dev/disk/by-path" | ||
# We can't ensure the mounted disk name is sda or sdb | ||
# But we can specify the disk logic unit number to 2 | ||
# We find the correct disk by the disk logic unit number from by-path directory | ||
target_str="lun-2-part1" | ||
disk_path_file=$(ls $disk_by_path_dir | grep $target_str) | ||
|
||
# Check whether the disk path file exists | ||
if [ -z "$disk_path_file" ]; then | ||
echo "Error: Disk path file not found." | ||
exit 1 | ||
fi | ||
|
||
# Check the number of lines returned | ||
line_count=$(echo "$disk_path_file" | wc -l) | ||
|
||
# If there are multiple lines, exit with status 1 | ||
if [ "$line_count" -ne 1 ]; then | ||
echo "Error: multiple disk path files found." | ||
exit 1 | ||
fi | ||
|
||
disk="${disk_by_path_dir}/${disk_path_file}" | ||
mkdir -p $mount_point | ||
mount $disk $mount_point | ||
|
||
# check whether it is the first time to boot | ||
first_boot_flag_file="/from_host/first_boot_flag" | ||
if [ -f $first_boot_flag_file ]; then | ||
exit 0 | ||
fi | ||
touch $first_boot_flag_file | ||
|
||
# execute entrance script | ||
init_file_name="entrance.sh" | ||
init_file=${mount_point}/${init_file_name} | ||
chmod +x $init_file | ||
source $init_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a new feature?
Wondering if you can use existing sonic feature:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to check whether it's the first boot here, if it's the first time, need to call the master script. If there is already one same feature, I can reuse the existing one. But after I checked, I don't think we can leverage the existing flag. Currently, we do "sudo sed -i '/^exit 0/i\bash /usr/sbin/kubernetes_master_entrance.sh' $FILESYSTEM_ROOT/etc/rc.local" when include k8s master feature. I see the "firsttime" flag aslo in rc.local file, but for grub staff. Not good to leverage, except we change rc.local file directly, I think there is no need to change rc.local file directly for k8s master feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean it's not good to use the existing feature. The reason is that we call the k8s master script in the last line of rc.local, but we don't change the rc.local file directly. We insert the call master script line by sed command when include_kubernetes_master=y. If we want to add the calling k8s master script to existing firsttime flag logic, we need to change the rc.local file directly, it's not easy to add lines to rc.local by sed command any more. If we agree to change the rc.local file directly, I can try to use the existing flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the point of
first_boot_flag
,kubernetes_master_entrance.sh
andsed -i '/^exit 0/i\bash /usr/sbin/kubernetes_master_entrance.sh' $FILESYSTEM_ROOT/etc/rc.local
.They are introduced for a deployment workflow, but this workflow is fragile. Suggest:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created #15849, and please consider it in future PR.