Minikube and non-default NodePorts - macos

I'm trying to start my dockerized application in a pod with a StatefulSet. The application uses around 20 ports, that are known by other services, so I'd like to expose them on the same port number as before the docker/k8s. For this I added port mappings in the service.yaml file like this:
- port: 8080
targetPort: 8080
nodePort: 8080
protocol: TCP
name: serverpool1
- port: 8081
targetPort: 8081
nodePort: 8081
protocol: TCP
name: serverpool2
To make this work I need to be able to use nodePorts not in the default range. For what I have seen it should work like this:
minikube start --extra-config=apiserver.ServiceNodePortRange=5000-46000
The issue is that if I have the --extra-config param, the minikube does not start, but gives an error:
Starting local Kubernetes v1.10.0 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
E0904 09:18:24.862606 28110 start.go:305] Error restarting cluster: restarting kube-proxy: waiting for kube-proxy to be up for configmap update: timed out waiting for the condition
Without the --extra-config parameter it starts normally, but I'm not able to have the lower ports.
I have a Mac with High Sierra, I use VirtualBox as VM, I have minikube version v0.28.2 and kubectl version:
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-08T16:31:10Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean", BuildDate:"2018-03-26T16:44:10Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

I think you are affected by problem described here: https://github.com/kubernetes/minikube/issues/2733 I reproduced that case on my minikube on Ubuntu 18.04 and I can confirm the same error so it looks more like problem/bug in minikube.

Related

How do I curl my elasticsearch on AWS EC2

I installed elasticsearch(docker) 8.2 on aws ec2(ubuntu 20.04.)
Everything is working.My only problem is that I can't reach(curl) it from other instances and my backend server(it is on same vpc).
I added my node to its discovery node, and also set network.host: 0.0.0.0
but I still can't reach it
(I tried with both private and public ip)
Is it necessary to install SSL/TSL on it with elastic 8?
Does anyone has any suggestion how to access it?
Looks like you forgot to bind the docker container port to host port, you need to add below config, to your Elasticsearch container docker yml
ports:
- "9202:9200" (bind 9200 port of host to docker port of 9200, 9200 is the Elasticsearch port by default)
After that you should be able to do the curl from other instances in the VPC.

Minikube : remote error tls: bad certificate

I'm following a Kubernetes tutorial, and cannot run first command (minikube start --vm-driver=hyperkit). I'm using a MacBook Pro Intel on macOs Monterey. I cannot make it work because of TLS error.
$ minikube start --vm-driver=hyperkit
😄 minikube v1.25.2 on Darwin 12.2.1
🆕 Kubernetes 1.23.3 is now available. If you would like to upgrade, specify: --kubernetes-version=v1.23.3
✨ Using the hyperkit driver based on existing profile
👍 Starting control plane node minikube in cluster minikube
🔄 Restarting existing hyperkit VM for "minikube" ...
🐳 Preparing Kubernetes v1.20.2 on Docker 20.10.3 ...
❌ Problems detected in etcd [592b8a58065e]:
2022-03-19 22:12:03.193985 I | embed: rejected connection from "127.0.0.1:38132" (error "remote error: tls: bad certificate", ServerName "")
I tried :
Restarted the computer : https://github.com/kubernetes/minikube/issues/4329
Used --embed-certs argument
$ minikube start --vm-driver=hyperkit --embed-certs
😄 minikube v1.25.2 on Darwin 12.2.1
🆕 Kubernetes 1.23.3 is now available. If you would like to upgrade, specify: --kubernetes-version=v1.23.3
✨ Using the hyperkit driver based on existing profile
👍 Starting control plane node minikube in cluster minikube
🔄 Restarting existing hyperkit VM for "minikube" ...
🐳 Preparing Kubernetes v1.20.2 on Docker 20.10.3 ...
❌ Problems detected in etcd [78d1e36569b8]:
2022-03-19 22:20:53.503532 I | embed: rejected connection from "127.0.0.1:34926" (error "remote error: tls: bad certificate", ServerName "")
I'm new to K8s, what could cause such behaviour ?
I installed minikube and hyperkit with homebrew. When I display the kubectl version I get another connection error :
kubectl version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.5", GitCommit:"5c99e2ac2ff9a3c549d9ca665e7bc05a3e18f07e", GitTreeState:"clean", BuildDate:"2021-12-16T08:38:33Z", GoVersion:"go1.16.12", Compiler:"gc", Platform:"darwin/amd64"}
Unable to connect to the server: dial tcp 192.168.64.2:8443: i/o timeout
The kubectl version error helped :
Unable to connect to the server: dial tcp i/o time out
It seems I had already played with k8s :
$ kubectl config view
apiVersion: v1
clusters:
- cluster:
certificate-authority: /Users/xxx/.minikube/ca.crt
extensions:
- extension:
last-update: Sat, 13 Mar 2021 13:40:06 CET
provider: minikube.sigs.k8s.io
version: v1.18.1
name: cluster_info
server: https://192.168.64.2:8443
name: minikube
contexts:
- context:
cluster: minikube
extensions:
- extension:
last-update: Sat, 13 Mar 2021 13:40:06 CET
provider: minikube.sigs.k8s.io
version: v1.18.1
name: context_info
namespace: default
user: minikube
name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
user:
client-certificate: /Users/xxx/.minikube/profiles/minikube/client.crt
client-key: /Users/xxx/.minikube/profiles/minikube/client.key
First I deleted the existing cluster :
$ kubectl config delete-cluster minikube
deleted cluster minikube from /Users/xxx/.kube/config
Then run
$ minikube delete
🔥 Deleting "minikube" in hyperkit ...
💀 Removed all traces of the "minikube" cluster.
Finally :
$ minikube start --vm-driver=hyperkit
😄 minikube v1.25.2 on Darwin 12.2.1
✨ Using the hyperkit driver based on user configuration
👍 Starting control plane node minikube in cluster minikube
💾 Downloading Kubernetes v1.23.3 preload ...
> preloaded-images-k8s-v17-v1...: 505.68 MiB / 505.68 MiB 100.00% 923.34 K
🔥 Creating hyperkit VM (CPUs=2, Memory=4000MB, Disk=20000MB) ...
🐳 Preparing Kubernetes v1.23.3 on Docker 20.10.12 ...
▪ kubelet.housekeeping-interval=5m
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔎 Verifying Kubernetes components...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟 Enabled addons: default-storageclass, storage-provisioner
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

Kubernetes NodePort url getting changed with "minikube service <service>"

I have created a NodePort to forward request from port 30101->80->8089:
apiVersion: v1
kind: Service
metadata:
name: gorest-service
spec:
type: NodePort
selector:
app: gorest
ports:
- protocol: TCP
port: 80
targetPort: 8089
nodePort: 30101
When I try to get the service URL http://192.168.49.2:30101, I am unable to access it, but with url http://127.0.0.1:64741, retrieved by using minikube service <service>, I am able to access.
Query: Unable to understand how http://192.168.49.2:30101 was changed to http://127.0.0.1:64741 retrived by minikube service <service>
% minikube service gorest-service
|-----------|----------------|-------------|---------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|----------------|-------------|---------------------------|
| default | gorest-service | 8089 | http://192.168.49.2:30101 |
|-----------|----------------|-------------|---------------------------|
🏃 Starting tunnel for service gorest-service.
|-----------|----------------|-------------|------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|----------------|-------------|------------------------|
| default | gorest-service | | http://127.0.0.1:64741 |
|-----------|----------------|-------------|------------------------|
🎉 Opening service default/gorest-service in default browser...
❗ Because you are using a Docker driver on darwin, the terminal needs to be open to run it.
In your manifest file you remap the service port inside the container from port 80 to port 8089.
If you want to access that service inside kubernetes you have to use the 8089 port.
BUT you cannot access services inside K8s from the outside world: you need to expose them (you should use a load balancer or an egress service).
Minikube is meant to be used for development. The 64741 port you see is a tunnel service that starts minikube and allows you to test and debug your service outside k8s without using an egress (which might be doing more than just connecting the service with the outside world, like for instance authenticating or authorizing requests).
Your understanding is correct, service exposed using NodePort should be reachable on minikube_IP:NodePort. First I checked it on Linux VM with minikube installed and it worked.
Then I noticed you're using MacOS:
Because you are using a Docker driver on darwin
Which leads us to some limitations with minikube running with docker driver on MacOS. Please see this GitHub issue.
There are two options at least (more, but these are simple to do):
use minikube tunnel what you did and it worked for you.
Tunnel is used to expose the service from inside of VM where minikube is running to the host machine's network. Please refer to access applications in minikube. This is how minikube_IP:NodePort transforms to localhost:different_port.
start minikube with VirtualBox driver to get a proper IP (if you really need to access your service on NodePort), below the command how to start it with VirtualBox driver (this should be installed on your machine):
minikube start --driver=VirtualBox

How to connect Minikube windows 10 connect to local cassandra DB

I have insatlled Below Softwares in windows 10
1.cassandra version 2.2.15
Docker version 19.03.2
3.minikube version: v1.4.0
4.helm client and sever v2.15.0-rc.1
kubectl client v1.14.6 and server v1.16.0
I am running cassandra DB in localhost port 9042 , i want to connect that localhost DB to my minikube helm with the IPaddress or hostname of the cassandra i am not able .
I am able to connect to the local cassandra db to Minikube cluster , need to change the
rpc_address in cassandra.yaml
rpc_address: <LOCAL_WINDOWS_IPV4_ADDR>
broadcast_rpc_address: 1.2.3.4

Kubernetes connection refused on port 8080 - Windows 10

I have following error on Windows10 after installing kubectl via
choco install kubernetes-cli:
PowerShell
PS C:\Users\userA> kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"windows/amd64"}
Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.
Cmd
C:\Users\userA>kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"windows/amd64"}
Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.
I have created .kube folder (C:\Users\userA\.kube) and inside of it an empty config file
I set windows environment variable:
Variable_name: KUBECONFIG
value: C:\Users\userA\.kube\config
EDIT: I tested it with running minikube:
You need to start the server first, with:
minikube start
Edit: As op tries to use hyper-v the following command tells minikube to use hyper-v
minikube start --vm-driver hyperv --hyperv-virtual-switch "Primary Virtual Switch"
To get this workling it is also neccessary to set a virtual switch named "Primary Virtual Switch" in hyper-v.
I've figured it out myself - on Windows 10
Hyper-V should be turn on if you are using Docker desktop but for minikube it should be turn off.
When i had turned off Hyper-V and restarted my PC - then minikube start worked fine.

Resources