Fork kubespray repo to your personal/organisation account on github. Note:
Add forked repo as submodule to desired folder in your existent ansible repo(for example 3d/kubespray):
git submodule add https://github.com/YOUR_GITHUB/kubespray.git kubespray
Git will create .gitmodules
file in your existent ansible repo:
[submodule "3d/kubespray"]
path = 3d/kubespray
url = https://github.com/YOUR_GITHUB/kubespray.git
Configure git to show submodule status:
git config --global status.submoduleSummary true
Add original kubespray repo as upstream:
git remote add upstream https://github.com/kubernetes-sigs/kubespray.git
Sync your master branch with upstream:
git checkout master
git fetch upstream
git merge upstream/master
git push origin master
Create a new branch which you will use in your working environment:
git checkout -b work
Never use master branch of your repository for your commits.
Modify path to library and roles in your ansible.cfg file (role naming should be uniq, you may have to rename your existent roles if they have same names as kubespray project):
...
library = 3d/kubespray/library/
roles_path = 3d/kubespray/roles/
...
Copy and modify configs from kubespray group_vars
folder to corresponding group_vars
folder in your existent project.
You could rename all.yml config to something else, i.e. kubespray.yml and create corresponding group in your inventory file, which will include all hosts groups related to kubernetes setup.
Modify your ansible inventory file by adding mapping of your existent groups (if any) to kubespray naming. For example:
...
#Kargo groups:
[kube-node:children]
kubenode
[k8s-cluster:children]
kubernetes
[etcd:children]
kubemaster
kubemaster-ha
[kube-master:children]
kubemaster
kubemaster-ha
[kubespray:children]
kubernetes
Now you can include kubespray tasks in you existent playbooks by including cluster.yml file:
- name: Include kubespray tasks
include: 3d/kubespray/cluster.yml
Or your could copy separate tasks from cluster.yml into your ansible repository.
Commit changes to your ansible repo. Keep in mind, that submodule folder is just a link to the git commit hash of your forked repo.
When you update your "work" branch you need to commit changes to ansible repo as well.
Other members of your team should use git submodule sync
, git submodule update --init
to get actual code from submodule.
If you made useful changes or fixed a bug in existent kubespray repo, use this flow for PRs to original kubespray repo.
Sign the CNCF CLA.
Change working directory to git submodule directory (3d/kubespray).
Setup desired user.name and user.email for submodule.
If kubespray is only one submodule in your repo you could use something like:
git submodule foreach --recursive 'git config user.name "First Last" && git config user.email "your-email-addres@used.for.cncf"'
Sync with upstream master:
git fetch upstream
git merge upstream/master
git push origin master
Create new branch for the specific fixes that you want to contribute:
git checkout -b fixes-name-date-index
Branch name should be self explaining to you, adding date and/or index will help you to track/delete your old PRs.
Find git hash of your commit in "work" repo and apply it to newly created "fix" repo:
git cherry-pick <COMMIT_HASH>
If you have several temporary-stage commits - squash them using git rebase -i
Also you could use interactive rebase (git rebase -i HEAD~10
) to delete commits which you don't want to contribute into original repo.
When your changes is in place, you need to check upstream repo one more time because it could be changed during your work.
Check that you're on correct branch:
git status
And pull changes from upstream (if any):
git pull --rebase upstream master
Now push your changes to your fork repo with git push
. If your branch doesn't exists on github, git will propose you to use something like git push --set-upstream origin fixes-name-date-index
.
Open you forked repo in browser, on the main page you will see proposition to create pull request for your newly created branch. Check proposed diff of your PR. If something is wrong you could safely delete "fix" branch on github using git push origin --delete fixes-name-date-index
, git branch -D fixes-name-date-index
and start whole process from the beginning.
If everything is fine - add description about your changes (what they do and why they're needed) and confirm pull request creation.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。