I want to remove Kubernetes from a Debian machine (I didn't do the setup)
I followed the instructions from How to completely uninstall kubernetes
kubeadm reset
sudo apt-get purge kubeadm kubectl kubelet kubernetes-cni kube*
sudo apt-get autoremove
sudo rm -rf ~/.kube
But it seems to be still installed:
# which kubeadm
/usr/local/bin/kubeadm
# which kubectl
/usr/local/bin/kubectl
# which kubelet
/usr/local/bin/kubelet
Also, apt list --installed | grep kube* does not return anything, so it make me think it was not installed via apt
Do you know how to clean this machine ? Should I just rm /usr/local/bin/kubectl etc ? I don't really like this idea..
Thanks for help
The method suggested by Rib47 on the answer you indicated is correct to completely remove and clean Kubernetes installed with apt-get.
As mentioned by underscore_d, /usr/local/bin/ isn't the directory where the packages installed by apt-get are placed.
For example, when you install kubectl using apt-get, it's placed on /usr/bin/kubectl and that's what is going to be removed by apt-get purge.
I tested it on my kubeadm cluster lab and I don't have these files at /usr/local/bin/.
You have to revisit all the steps you followed during the install process to know how exactly these files got there.
If you run kubeadm reset, I would say it's safe to remove these files. I suggest you to check if they are being used before removing using the command fuser. This command might not be installed in your linux and you can install it by running sudo apt-get install psmisc. After installing you can run it as in this example:
$ sudo fuser /usr/bin/kubelet
/usr/bin/kubelet: 21167e
It means this file is being used by process number 21167.
Checking this process we can see what's using it:
$ ps -aux | grep 21167
root 21167 4.1 0.5 788164 88696 ? Ssl 08:50 0:07 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --cgroup-driver=cgroupfs --network-plugin=cni --pod-infra-container-image=k8s.gcr.io/pause:3.2
If the files related to kubernetes you have under /usr/local/bin/ are not in use, I would remove them with no worries.
Related
I have installed some packages (Docker, Kubeadm, Kubelet, Kubectl) for my Kubernetes cluster on Ubuntu 18.04 LTS.
I don't want these packages to get auto updated because there will be some issue arises between them when the update happens between one another.
I just want to update manually when they are stable.
What is the correct command for stop packages update automatically?
Commands I have used to install them on Ubuntu 18.04
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install -y docker-ce=18.06.1~ce~3-0~ubuntu
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt-get update
sudo apt-get install -y kubelet=1.12.7-00 kubeadm=1.12.7-00 kubectl=1.12.7-00
Motivation: You don't want to take any risks over sensitive packages on your linux machine (It happens when your application is in production and customers use it, or some important task running inside, newer version can break changes and accidentally can cause a downtime). In this situation - you want to pin specific versions to your packages and make sure no upgrade happens without explicit action and approval from your side.
Solution: You should disable the unattended-upgrades feature and pin your package into the current version you use (in other words - keep this version).
step 1: disable automatic upgrade (aka unattended-upgrades)
$ sudo vim /etc/apt/apt.conf.d/20auto-upgrades
#edit these lines - which disabling the upgrade feature.
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "0";
step 2: hold and freeze the specific package you want prevent from self upgrading:
sudo apt-mark hold <package-name>
You can use the hold status for a package (or set of packages) to not involve it upgrades. That gives you the more fine-tuned ability to decide on a per-package basis what should, or should not, upgrade. Very helpful during known digressions, bugs, and subtle changes in behaviour.
From the manual page for dpkg and edited / indented:
--get-selections [package-name-pattern...]
Get list of package selections, and write it to stdout. Without a pattern,
non-installed packages (i.e. those which have been previously purged) will
not be shown.
--set-selections
Set package selections using file read from stdin. This file should be in
the format “package state”, where state is one of install, hold, deinstall
or purge. Blank lines and comment lines beginning with ‘#’ are also
permitted.
The available file needs to be up-to-date for this command to be useful,
otherwise unknown packages will be ignored with a warning. See the
--update-avail and --merge-avail commands for more information.
The format is arguably a little weird -- but this is very powerful and helpful. I relied on it a few times during my twenty-five years (!!) with Debian/Ubuntu. I may have a shell script helper somwhere but I may need to dig.
Find of the day :). Ubuntu apt gives you the command to hold the auto update of the package. Thanks to Dirk for giving me the hint.
sudo apt-mark hold docker-ce kubelet kubeadm kubectl
apt doesn't have yum like flags --enable-repo and --disablerepo while performing install or update. A way to manage repos is shown here
But for your case the way you have added the repositories they have been appended to /etc/apt/sources.list therefore you can use sed to comment out the repository lines which you have added to install docker and kubernetes.
Note: you should comment out lines after installation and before performing sudo apt-get update
Example:To disable docker repo:
sed -i 's/^deb.*docker.*/# &/g' /etc/apt/sources.list
Enable the docker repo for manual update:
sed -i '/^# deb .*docker.*/s/^# //' /etc/apt/sources.list
I am running Ansible playbook and trying to install OS dependencies packages for python. I am trying to run the following:
sudo yum install gcc gcc-c++ libffi-devel python-devel python-pip python-wheel openssl-devel libsasl2-devel openldap-devel
However, it fails at installing libsasl2-devel with the message:
"No package matching 'libsasl2-devel' found available, installed or updated"
All my instances are Amazon Linux 2 machines. Is there any alternative package for this? I tried to look into this but I found solutions for Ubuntu only.
I was able to get it to work in a series of steps. Its a yum issue after other databases are installed and not cleaned up before installing mysql
clear sasl first: sudo yum remove cyrus-sasl
if you have installed maria, there will be conflicts, remove that as well
sudo yum remove mariadb mariadb-server mariadb-libs
take note of anything uninstalled by this to re-add later. If this is too much, you can take a risk and not remove sasl, but it might not reset the availability of the package.
Start here to clean up the dependency issues: https://serverfault.com/questions/873955/how-solve-mysql-5-7-dependency follow the command given by clean all as sudo rm -rf /var/cache/yum/*
This can possibly resolve your issues right there, if not continue the installation below.
delete all data left in /var/lib/mysql/ or you may have upgrade issues.
resinstall sasl:
sudo yum install cyrus-sasl cyrus-sasl-devel and any other packages removed above.
Establish mysql5.7 with the yum services.
wget https://dev.mysql.com/get/mysql57-community-release-el6-11.noarch.rpm
sudo yum localinstall -y mysql57-community-release-el6-11.noarch.rpm
sudo yum repolist enabled | grep "mysql.*-community.*"
sudo yum repolist enabled | grep mysql
sudo yum install -y mysql-community-common mysql-community-libs mysql-community-server mysql-community-client
if that doesn't work, re-clear the yum cache again and re-run sudo yum install -y mysql-community-server
if that works, then
sudo service mysqld start
IF the /var/lib/mysql is empty, it will have created a temporary password in the /var/log/mysqld.log (use sudo to read)
run sudo mysql_secure_installation and establish your real password and security settings.
now you should have access via mysql -u root -p
It is my first attempt to set up project with JavaScript tools. According to README I need to install and run yarn. I am getting this error:
The engine "node" is incompatible with this module. Expected version "6.x".
It happened (don't ask me how, I know it's bad but I was lazy and was just copying commands from the Internet), that I have two versions of node in my system (Ubuntu 16.04 LTS):
/usr/bin/node --version
v6.11.4
and
/usr/local/bin/node --version
v8.6.0
The default one is:
which node
/usr/local/bin/node
And I guess I need older version from /usr/bin/node.
How can I use by default desired one and maybe delete not needed version without creating more chaos in my system?
I will recommend you uninstall them both so that you can run the installation of one among the two of the Node.JS.
rm -r /usr/local/bin/node
rm -r /usr/bin/node
Again you can run these sudo apt-get purge --auto-remove nodejs which should remove of the gyp, linux-headers-4.4.0-18-generic etc packages.
Since you're running on Ubuntu Linux, you can install Yarn via our Debian package repository. You will first need to configure the repository:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
Then you can simply:
sudo apt-get update && sudo apt-get install yarn
This should install yarn for you.
I'm trying to install the gitlab-ce package on a system running Ubuntu server 17.04. I followed the official installation instructions here.
First I ran:
sudo apt-get install curl openssh-server ca-certificates postfix
I already had all of those installed. Then I ran:
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
Which also worked fine. But when I try to run
sudo apt-get install gitlab-ce
I get the following error message:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package gitlab-ce
I know it's possible to install gitlab on Ubuntu server 17.04, since I had already done It on a previous installation. Unfortunately I installed the OS again from scratch and I can't remember how I had installed gitlab.
Thanks for any help in advance!
I gave up with the "full" automated script, as it doesn't appear to be working with 17.04... Anyway. I grabbed the latest package from https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/xenial/gitlab-ce_9.3.0-ce.0_amd64.deb
curl -LJO https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/xenial/gitlab-ce_9.3.0-ce.0_amd64.deb/download
Installed it with the package manager
sudo dpkg -i gitlab-ce_9.3.0-ce.0_amd64.deb
Then configured it with
sudo gitlab-ctl reconfigure
Then, point your web browser at your new gitlab install and you should be good to go...
Ubuntu 20.04.1
Incase anyone bumps back into this, while trying to gitlab on version 20.0.4 of ubuntu, life is much easier... and the instructions and automated script actually work. GitLab-CE installation instructions
on a fresh install of ubuntu: -
sudo apt install curl
curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab- ce/script.deb.sh | sudo bash
sudo apt install gitlab-ce
done!
I was facing the same problem (Lubuntu 17.10), after searching the gitlab forums for 2 Hours, I found this thread.
So from what I have read: Gitlab-ce is not supported for zesty yet. Also the simple
sudo apt-get install gitlab
is a wrong prompt cause it installs a Ubuntu package created by a user named as "praveen" and It is not officially supported by Gitlab.
here is what I did To solve my problem:
sudo nano /etc/apt/sources.list.d/gitlab_gitlab-ce.list.save
sudo nano /etc/apt/sources.list.d/gitlab_gitlab-ce.list
replace "zesty" with "xenial" (These files are root access only)
sudo apt update
sudo apt-get install gitlab-ce
This worked for me.
I have spent my whole afternoon for solving this problem, I hope this solution works for you too.
Prost !
EDIT: corrected spelling
I had the same problem getting the install to run on 17.10. According to an issue on their site ( https://gitlab.com/gitlab-org/gitlab-runner/issues/2851 ), the artful packages are not being built.
I did the same this as #DevX, but just changed the parameters on their setup script.
Howler#GitLab:/tmp$ curl -LO https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh
Howler#GitLab:/tmp$ sudo os=ubuntu dist=xenial bash ./script.deb.sh
Howler#GitLab:/tmp$ sudo apt-get install gitlab-ce
I have installed docker on my host virtual machine. And now want to create a file using vi.
But it's showing me an error:
bash: vi: command not found
login into container with the following command:
docker exec -it <container> bash
Then , run the following command .
apt-get update
apt-get install vim
The command to run depends on what base image you are using.
For Alpine, vi is installed as part of the base OS. Installing vim would be:
apk -U add vim
For Debian and Ubuntu:
apt-get update && apt-get install -y vim
For CentOS, vi is usually installed with the base OS. For vim:
yum install -y vim
This should only be done in early development. Once you get a working container, the changes to files should be made to your image or configs stored outside of your container. Update your Dockerfile and other files it uses to build a new image. This certainly shouldn't be done in production since changes inside the container are by design ephemeral and will be lost when the container is replaced.
USE THIS:
apt-get update && apt-get install -y vim
Explanation of the above command
apt-get update => Will update the current package
apt-get install => Will install the package
-y => Will by pass the permission, default permission will set to Yes.
vim => Name of the package you want to install.
Your container probably haven't installed it out of the box.
Run apt-get install vim in the terminal and you should be ready to go.
Add the following line in your Dockerfile then rebuild the docker image.
RUN apt-get update && apt-get install -y vim
Alternatively, keep your docker images small by not installing unnecessary editors. You can edit the files over ssh from the docker host to the container:
vim scp://remoteuser#container-ip//path/to/document
error:: bash: vi: command not found
run the below command by logging as root user to the container--
docker exec --user="root" -it (container ID) /bin/bash
apt-get update
apt-get install vim
Use below command in Debian based container:
apt-get install vim-tiny
Complete instruction for using in Dockerfile:
RUN apt-get update && apt-get install --no-install-recommends -y \
vim-tiny \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
It doesn't install unnecessary packages and removes unnecessary downloaded files, so your docker image size won't increase dramatically.
The most voted answer has the correct idea, however, it did not work in my case. The comment from #java25 did the trick in my case. I had to log into the docker container as a root user to install vim. I am just posting the comment as an answer so that it is easier for others, having the similar problem, to find it.
docker exec -ti --user root <container-id> /bin/bash
Once you are inside docker, run the following commands now to install vi.
apt-get update
apt-get install vim
To install within your Docker container you can run command
docker exec apt-get update && apt-get install -y vim
But this will be limited to the container in which vim is installed.
To make it available to all the containers, edit the Dockerfile and add
RUN apt-get update && apt-get install -y vim
or you can also extend the image in the new Dockerfile and add above command. Eg.
FROM < image name >
RUN apt-get update && apt-get install -y vim
Inside container (in docker, not in VM), by default these are not installed.
Even apt-get, wget will not work. My VM is running on Ubuntu 17.10. For me yum package manager worked.
Yum is not part of Debian or ubuntu. It is part of red-hat. But, it works in Ubuntu and it is installed by default like apt-get
To install vim, use this command
yum install -y vim-enhanced
To uninstall vim :
yum uninstall -y vim-enhanced
Similarly,
yum install -y wget
yum install -y sudo
-y is for assuming yes if prompted for any question asked after doing yum install package-name
error:: bash: vim: command not found
Run the below command by logging as root user to the container:
microdnf install -y vim
If you actually want a small editor for simple housekeeping in a docker, use this in your Dockerfile:
RUN apt-get install -y busybox && ln -s /bin/busybox /bin/vi
I used it on an Ubuntu 18 based docker.
(Of course you might need an RUN apt-get update before it but if you are making your own Docker file you probably already have that.)
Usually changing a file in a docker container is not a good idea. Everyone will forget about the change after a while. A good way is to make another docker image from the original one.
Say in a docker image, you need to change a file named myFile.xml under /path/to/docker/image/. So, you need to do.
Copy myFile.xml in your local filesystem and make necessary changes.
Create a file named 'Dockerfile' with the following content-
FROM docker-repo:tag
ADD myFile.xml /path/to/docker/image/
Then build your own docker image with docker build -t docker-repo:v-x.x.x .
Then use your newly build docker image.