Instance metadata on IBM Cloud - kubernetes

Is there any way to get instance metadata on IBM Cloud Kubernetes cluster, from internal pod? Something like doing curl to http://metadata.google.internal/computeMetadata/v1/instance/... on GKE clusters, or http://169.254.169.254/latest/... on EKS clusters.
Any help will be appreciated. Thanks!

I think I follow what you're after.. you're able to get details/metadata about your worker node from the SoftLayer APIs available - https://sldn.softlayer.com/reference/softlayerapi/
For k8s specific info you can utilize the k8s api-server to query metadata about things like the node, pods, etc at the Kubernetes.default.svc.cluster.local address from inside a pod. You can find the service account and token from within your pod at /var/run/secrets/kubernetes.io
Hope that helps.

Related

How to Kubernetes Cloud like GKE , EKS,.. allocation external ip for Service with Type Loadbacer in Kubernetes?

I just new in K8s. I try to self deploy k8s cloud in internal company server. And I have question how to I setup my K8s can allocation External IP for Service with Loabalancer. May you tell you how it work in GKE or EKS?
Updated base on your comment.
What I mean how to EKS or GKE behind the scenes allocation ip, what is a mechanism?
Here's the EKS version and here's the GKE version. It's a complex thing, suggest you use these materials as the starting point before diving into technical details (which previous answer provided you the source). In case you thought of on-premises k8s cluster, it depends on the CNI that you will use, a well known CNI is Calico.
In GKE you can define services to expose or to make accessible the applications defined in the cluster. There are several kinds of services one of them is a LoadBalancer service, this can have an external IP address.

Kubernetes Cluster: How to figure out which nodes are master nodes

When I use the command kubectl get nodes. I got list of nodes with ROLES . Are there any way I can find out which nodes are masters?
Use this command for this purpose.
kubectl get node --selector='node-role.kubernetes.io/master'
In EKS, according to the AWS Documentation:
The control plane runs in an account managed by AWS, and the Kubernetes API is exposed via the Amazon EKS endpoint associated with your cluster.
As mentioned in my comment above, you don't have access to the master node in an EKS cluster, as it is managed by AWS.
The idea behind it is to "make your life easier" and make you worry only about the loads that will run on the worker nodes.
There is also this documentation page, that may help in the understanding of EKS.

How to deploy Open Policy Agent in a Google Kubernetes cluster

I'm new to k8s, and I want to deploy OPA in the same pod as of my application in Google Kubernetes engine. But I don't know how to do this.Are there any references that I can refer more details about this ? Could you please help me figure out the steps I should follow ?
It should similar as deploying to any Kubernetes cluster as documented here. The difference could be you may want to use a LoadBalancer type service instead of NodePort.

How to allow nodes of one GKE cluster to connect to another GKE

I have a GKE clusters setup, dev and stg let's say, and wanted apps running in pods on stg nodes to connect to dev master and execute some commands on that's GKE - I have all the setup I need and when I add from hand IP address of the nodes all works fine but the IP's are changing,
so my question is how can I add to Master authorised networks the ever-changing default-pool IPs of nodes from the other cluster?
EDIT: I think I found the solution, it's not the node IP but the NAT IP I have added to authorized networks, so assuming I don't change those I just need to add the NAT I guess, unless someone knows better solution ?
I'm not sure that you are doing the correct things. In kubernetes, your communication is performed between services, that represents deployed pods, on one or several nodes.
When you communicate with the outside, you reach an endpoint (an API or a specific port). The endpoint is materialized by a loadbalancer that routes the traffic.
Only the kubernetes master care about the node as resources (CPU, memory, GPU,...) provider inside the cluster. You should never have to directly reach the node of a cluster without using the standard way.
Potentially you can reach the NodePort service exposal on the NodeIP+servicePort.
What you really need to do is configure the kubectl in jenkins pipeline to connect to GKE Master IP. The master is responsible for accepting your commands (rollback, deployment, etc). See Configuring cluster access for kubectl
The Master IP is available in the Kubernetes Engine console along with the Certificate Authority certificate. A good approach is to use a service account token to authenticate with the master. See how to Login to GKE via service account with token.

Persistent Storage (Gluster/Other storage) for Kubernetes

I am trying to setup Kubernetes with Gluster using Heketi. After several tries, i am still not able to get it working. I am using RancherOS with Rancher application running on it which manages Kubernetes. I am now looking for alternative approaches.
1) Setup GlusterFS and Heketi on a standalone RHEL host:
In this case, my question is whether it's even possible to manage a Kubernetes cluster present on another set of hosts or do i need to have GlusterFS servers present on the same hosts that Kubernetes manages? If it's the former, then will i have to mount the gluster partition on Kubernetes node?
2) Kubernetes with any other persistent storage provider:
We cannot use cloud providers for sure. Paid ones are also not an option so i was considering Ceph. Anyone with successful implementation and whether we have something similar to Heketi for Ceph setup?
#Technext, we can help you to configure heketi + gluster configuration in kubernetes setup. We have many users who has already configured the same. If you havent tried this please check gluster-kubernetes repo https://github.com/gluster/gluster-kubernetes.
Can you please let us know the error you are into when you deploy Heketi gluster ? We can try to help you to achieve this target.
Waiting for your reply.