Рубрики
k8s

K8S

Sort pods by creation time:
kubectl get pods --sort-by=.metadata.creationTimestamp


Enable kubelet to log level 5:
sed -i -e 's/--v=1/--v=5/g' /etc/systemd/system/kubelet.service; systemctl daemon-reload; systemctl restart kubelet

Check pod-eviction-timeout:
grep pod-eviction-timeout /etc/kubernetes/manifests/kube-controller-manager.yml

Change pod-eviction-timeout:
sed -i 's/- --pod-eviction-timeout=120s/- --pod-eviction-timeout=5m/g' /etc/kubernetes/manifests/kube-controller-manager.yml

Get pod information in yaml format:
kubectl get pod POD_NAME -o yaml

Рубрики
NTP

NTP

Install NTP:
yum install -y ntp


firewalld open service:
firewall-cmd —add-service=ntp —permanent
firewall-cmd —reload


Start and enable:
systemctl start ntpd;
systemctl enable ntpd;
systemctl status ntpd;


Synchronize with NTP server and check date:
ntpq -p
date -R


Synchronize with the special server:
ntpdate -q ntp-server.url

Complete flow in one string:

yum install -y ntp; firewall-cmd --add-service=ntp --permanent; firewall-cmd --reload; systemctl start ntpd; systemctl enable ntpd; systemctl status ntpd; ntpq -p; date -R

Рубрики
Git

Git

Initialize a new git repository:
in target folder execute:
git init


How to add a local ssh key to GitHub:
generate ssh key on Linux VM:
ssh-keygen

copy the public key from target folder, by default /home/username/.id_rsa.pub
cat /home/username/.id_rsa.pub

paste key to GitHub:
user settings —> SSH and GPG keys —> New ssh key



Add remote repository:
git remote add origin git@github.com:username/repository_name.git



Check on what branch you are:
git branch

Check what local and remote branches git knows about:
git branch -a

Switch to the existing branch:
git checkout "existing-branch-name"

Create a new branch:
git checkout -b "new-branch-name"

Push the new branch to remote:
git push -u origin "new-branch-name"

Create an existing branch and move HEAD there:
git checkout -b "new-branch-name" "existing-branch-name"

Fetch all info about remote branches:
git fetch --all

Diff one branch against another:
git diff master..staging

Rename git branch:
git branch -m "existing-branch-name" "new-branch-name"

Help and man:
git help branch
git branch --help
man git-branch

Delete a branch:
git branch -d "branch-name-to-delete"


Forcefully delete a branch (think twice before using it):
git branch -d --force "branch-name-to-delete"

Full new feature flow:
# Start a new feature
git checkout -b new-feature master

# Edit some files
git add <file>
git commit -m "Start a feature"


# Edit some files
git add <file>
git commit -m "Finish a feature"


# Merge in the new-feature branch
git checkout master
git merge new-feature
git branch -d new-feature

Рубрики
Jenkins

Jenkins notes

How to reboot Jenkins from UI:

Safe reboot (Jenkins will wait for all jobs to finish):
{Jenkins_url}/safeRestart

Reboot (Jenkins will reboot immediately):
{Jenkins_url}/restart



####################################################

Jenkins update:

Find where Jenkins war file is located:
find / -name *.war

Rename original «jenkins.war» file in «/usr/lib/jenkins» to something like jenkins.war.20200426.bak

Download new «jenkins.war» file and put it in «/usr/lib/jenkins»

Restart Jenkins from UI or CLI:
systemctl restart jenkins



####################################################

Jenkins remote CLI:
jar can be downloaded from:
{Jenkins_url}/jnlpJars/jenkins-cli.jar
or
from web UI:
{Jenkins_url}/cli/



####################################################

Jenkins environment variables for CLI:

Linux:
Auth:
export JENKINS_USER_ID=username
export JENKINS_API_TOKEN=312312312312-token


Powershell:
Auth:
$env:JENKINS_USER_ID-«username«
$env:JENKINS_API_TOKEN-«312312312312-token«


####################################################

Jenkins build job on GitHub commit.

Install plugin in Jenkins named:
«GitHub plugin»

Configure job:
Check option
General —> GitHub project
and provide link ssh or https to your project.

and check the option:
Build Triggers —> GitHub hook trigger for GITScm polling

apply and save