question stringlengths 11 28.2k | answer stringlengths 26 27.7k | tag stringclasses 130
values | question_id int64 935 78.4M | score int64 10 5.49k |
|---|---|---|---|---|
In this official document, it can run command in a yaml config file:
https://kubernetes.io/docs/tasks/configure-pod-container/
apiVersion: v1
kind: Pod
metadata:
name: hello-world
spec: # specification of the pod’s contents
restartPolicy: Never
containers:
- name: hello
image: "ubuntu:14.04"
env:
... | command: ["/bin/sh","-c"]
args: ["command one; command two && command three"]
Explanation: The command ["/bin/sh", "-c"] says "run a shell, and execute the following instructions". The args are then passed as commands to the shell. In shell scripting a semicolon separates commands, and && conditionally runs the follow... | Kubernetes | 33,887,194 | 222 |
I am trying to build and deploy microservices images to a single-node Kubernetes cluster running on my development machine using minikube. I am using the cloud-native microservices demo application Online Boutique by Google to understand the use of technologies like Kubernetes, Istio etc.
Link to github repo: microser... | There are a few reasons why you encounter these errors:
There might be an issue with the existing cache and/or disc space. In order to fix it you need to clear the APT cache by executing: sudo apt-get clean and sudo apt-get update.
The same goes with existing docker images. Execute: docker image prune -f and docker c... | Kubernetes | 62,473,932 | 221 |
I've read a couple of passages from some books written on Kubernetes as well as the page on headless services in the docs. But I'm still unsure what it really actually does and why someone would use it. Does anyone have a good understanding of it, what it accomplishes, and why someone would use it?
| Well, I think you need some theory. There are many explanations (including the official docs) across the whole internet, but I think Marco Luksa did it the best:
Each connection to the service is forwarded to one randomly selected
backing pod. But what if the client needs to connect to all of those
pods? What if the b... | Kubernetes | 52,707,840 | 220 |
This is what I keep getting:
[root@centos-master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nfs-server-h6nw8 1/1 Running 0 1h
nfs-web-07rxz 0/1 CrashLoopBackOff 8 16m
nfs-web-fdr9h 0/1 CrashLoopBackOff 8 16m... | As @Sukumar commented, you need to have your Dockerfile have a Command to run or have your ReplicationController specify a command.
The pod is crashing because it starts up then immediately exits, thus Kubernetes restarts and the cycle continues.
| Kubernetes | 41,604,499 | 217 |
I have a pod test-1495806908-xn5jn with 2 containers. I'd like to restart one of them called container-test. Is it possible to restart a single container within a pod and how? If not, how do I restart the pod?
The pod was created using a deployment.yaml with:
kubectl create -f deployment.yaml
|
Is it possible to restart a single container
Not through kubectl, although depending on the setup of your cluster you can "cheat" and docker kill the-sha-goes-here, which will cause kubelet to restart the "failed" container (assuming, of course, the restart policy for the Pod says that is what it should do)
how do I... | Kubernetes | 46,123,457 | 210 |
I inherited a Kubernetes/Docker setup, and I accidentally crashed the pod by changing something relating to the DB password.
I am trying to troubleshoot this.
I don't have much Kubernetes or Docker experience, so I'm still learning how to do things.
The value is contained inside the db-user-pass credential I believe, w... | You can use kubectl get secrets/db-user-pass -o yaml or -o json where you'll see the base64-encoded username and password. You can then copy the value and decode it with something like echo <ENCODED_VALUE> | base64 -d.
A more compact one-liner for this:
kubectl get secrets/db-user-pass --template={{.data.password}} | ... | Kubernetes | 56,909,180 | 207 |
I've been doing a lot of digging on Kubernetes, and I'm liking what I see a lot! One thing I've been unable to get a clear idea about is what the exact distinctions are between the Deployment and StatefulSet resources and in which scenarios would you use each (or is one generally preferred over the other).
| Deployments and ReplicationControllers are meant for stateless usage and are rather lightweight. StatefulSets are used when state has to be persisted. Therefore the latter use volumeClaimTemplates / claims on persistent volumes to ensure they can keep the state across component restarts.
So if your application is state... | Kubernetes | 41,583,672 | 206 |
I just upgraded kubeadm and kubelet to v1.8.0. And install the dashboard following the official document.
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
After that, I started the dashboard by running
$ kubectl proxy --address="192.168.0... |
As of release 1.7 Dashboard supports user authentication based on:
Authorization: Bearer <token> header passed in every request to Dashboard. Supported from release 1.6. Has the highest priority. If present, login view will not be shown.
Bearer Token that can be used on Dashboard login view.
Username/password that ca... | Kubernetes | 46,664,104 | 198 |
I would like to see all resources in a namespace.
Doing kubectl get all will, despite of the name, not list things like services and ingresses.
If I know the the type I can explicitly ask for that particular type, but it seems there is also no command for listing all possible types. (Especially kubectl get does for exa... | Based on this comment , the supported way to list all resources is to iterate through all the api versions listed by kubectl api-resources:
kubectl api-resources enumerates the resource types available in your cluster.
this means you can combine it with kubectl get to actually list every instance of every resource typ... | Kubernetes | 47,691,479 | 198 |
I am looking to list all the containers in a pod in a script that gather's logs after running a test. kubectl describe pods -l k8s-app=kube-dns returns a lot of info, but I am just looking for a return like:
etcd
kube2sky
skydns
I don't see a simple way to format the describe output. Is there another command? (and ... | Answer
kubectl get pods POD_NAME_HERE -o jsonpath='{.spec.containers[*].name}'
Explanation
This gets the JSON object representing the pod. It then uses kubectl's JSONpath to extract the name of each container from the pod.
| Kubernetes | 33,924,198 | 192 |
I've created a secret using
kubectl create secret generic production-tls \
--from-file=./tls.key \
--from-file=./tls.crt
If I'd like to update the values - how can I do this?
| This should work:
kubectl create secret generic production-tls \
--save-config \
--dry-run=client \
--from-file=./tls.key --from-file=./tls.crt \
-o yaml | \
kubectl apply -f -
| Kubernetes | 45,879,498 | 187 |
I have 3 nodes, running all kinds of pods. I would like to have a list of nodes and pods, for an example:
NODE1 POD1
NODE1 POD2
NODE2 POD3
NODE3 POD4
How can this please be achieved?
| You can do that with custom columns:
kubectl get pod -o=custom-columns=NAME:.metadata.name,STATUS:.status.phase,NODE:.spec.nodeName --all-namespaces
or just:
kubectl get pod -o=custom-columns=NODE:.spec.nodeName,NAME:.metadata.name --all-namespaces
| Kubernetes | 48,983,354 | 184 |
When I run kubectl -n abc-namespace describe pod my-pod-zl6m6, I get a lot of information about the pod along with the Events in the end.
Is there a way to output just the Events of the pod either using kubectl describe or kubectl get commands?
Edit:
This can now (kubernetes 1.29) be achieved via the following command ... | You can use the event command of kubectl.
To filter for a specific pod you can use a field-selector:
kubectl get event --namespace abc-namespace --field-selector involvedObject.name=my-pod-zl6m6
To see what fields are possible you can use kubectl describe on any event.
| Kubernetes | 51,931,113 | 184 |
Every time a deployment gets updated, a new replica set is added to a long list. Should the old rs be cleaned?
| Removing old replicasets is part of the Deployment object, but it is optional. You can set .spec.revisionHistoryLimit to tell the Deployment how many old replicasets to keep around.
Here is a YAML example:
apiVersion: apps/v1
kind: Deployment
# ...
spec:
# ...
revisionHistoryLimit: 0 # Default to 10 if not specifie... | Kubernetes | 37,255,731 | 182 |
I have a MySQL pod running in my cluster. I need to temporarily pause the pod from working without deleting it, something similar to docker where the docker stop container-id cmd will stop the container not delete the container. Are there any commands available in kubernetes to pause/stop a pod?
| So, like others have pointed out, Kubernetes doesn't support stop/pause of current state of pod and resume when needed. However, you can still achieve it by having no working deployments which is setting number of replicas to 0.
kubectl scale --replicas=0 deployment/<your-deployment>
see the help
# Set a new size for ... | Kubernetes | 54,821,044 | 176 |
Is there a way to automatically remove completed Jobs besides making a CronJob to clean up completed Jobs?
The K8s Job Documentation states that the intended behavior of completed Jobs is for them to remain in a completed state until manually deleted. Because I am running thousands of Jobs a day via CronJobs and I don'... | You can now set history limits, or disable history altogether, so that failed or successful CronJobs are not kept around indefinitely. See my answer here. Documentation is here.
To set the history limits:
The .spec.successfulJobsHistoryLimit and .spec.failedJobsHistoryLimit fields are optional. These fields specify h... | Kubernetes | 41,385,403 | 174 |
I just saw some of my pods got evicted by kubernetes. What will happen to them? just hanging around like that or I have to delete them manually?
| A quick workaround I use, is to delete all evicted pods manually after an incident. You can use this command:
kubectl get pods --all-namespaces -o json | jq '.items[] | select(.status.reason!=null) | select(.status.reason | contains("Evicted")) | "kubectl delete pods \(.metadata.name) -n \(.metadata.namespace)"' | xarg... | Kubernetes | 46,419,163 | 174 |
When I push my deployments, for some reason, I'm getting the error on my pods:
pod has unbound PersistentVolumeClaims
Here are my YAML below:
This is running locally, not on any cloud solution.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert
kompose.versio... | You have to define a PersistentVolume providing disc space to be consumed by the PersistentVolumeClaim.
When using storageClass Kubernetes is going to enable "Dynamic Volume Provisioning" which is not working with the local file system.
To solve your issue:
Provide a PersistentVolume fulfilling the constraints of the... | Kubernetes | 52,668,938 | 172 |
I have been trying to follow the getting started guide to EKS.
When I tried to call kubectl get service I got the message: error: You must be logged in to the server (Unauthorized)
Here is what I did:
1. Created the EKS cluster.
2. Created the config file as follows:
apiVersion: v1
clusters:
- cluster:
server: htt... |
When an Amazon EKS cluster is created, the IAM entity (user or role) that creates the cluster is added to the Kubernetes RBAC authorization table as the administrator. Initially, only that IAM user can make calls to the Kubernetes API server using kubectl.
eks-docs
So to add access to other aws users, first
you must ... | Kubernetes | 50,791,303 | 171 |
What is the username/password/keys to ssh into the Minikube VM?
| You can use the Minikube binary for this, minikube ssh.
| Kubernetes | 38,870,277 | 167 |
I can specify a specific version of a chart by doing: helm install --version <some_version> stable/<some_chart>
But, how do I know which versions are available?
| Short Answer
You can list all available versions of a chart using the search repo functionality together with the --versions flag:
helm search repo <reponame>/<chartname> --versions
This requires that the repo was added previously and is up to date. If your repo was added some time ago, please make sure to keep the loc... | Kubernetes | 51,031,294 | 162 |
I looking for the option to list all pods name
How to do without awk (or cut). Now i'm using this command
kubectl get --no-headers=true pods -o name | awk -F "/" '{print $2}'
| Personally I prefer this method because it relies only on kubectl, is not very verbose and we don't get the pod/ prefix in the output:
kubectl get pods --no-headers -o custom-columns=":metadata.name"
| Kubernetes | 35,797,906 | 161 |
I can sort my Kubernetes pods by name using:
kubectl get pods --sort-by=.metadata.name
How can I sort them (or other resoures) by age using kubectl?
| Pods have status, which you can use to find out startTime.
I guess something like kubectl get po --sort-by=.status.startTime should work.
You could also try:
kubectl get po --sort-by='{.firstTimestamp}'.
kubectl get pods --sort-by=.metadata.creationTimestamp Thanks @chris
Also apparently in Kubernetes 1.7 release, so... | Kubernetes | 45,310,287 | 161 |
Kubernetes is billed as a container cluster "scheduler/orchestrator", but I have no idea what this means. After reading the Kubernetes site and (vague) GitHub wiki, the best I can tell is that its somehow figures out what VMs are available/capable of running your Docker container, and then deploys them there. But that ... | The purpose of Kubernetes is to make it easier to organize and schedule your application across a fleet of machines. At a high level it is an operating system for your cluster.
Basically, it allows you to not worry about what specific machine in your datacenter each application runs on. Additionally it provides gener... | Kubernetes | 28,086,732 | 160 |
I am relatively new to all these, but I'm having troubles getting a clear picture among the listed technologies.
Though, all of these try to solve different problems, but do have things in common too. I would like to understand what are the things that are common and what is different. It is likely that the combinatio... | Disclosure: I'm a lead engineer on Kubernetes
I think that Mesos and Kubernetes are largely aimed at solving similar problems of running clustered applications, they have different histories and different approaches to solving the problem.
Mesos focuses its energy on very generic scheduling, and plugging in multiple di... | Kubernetes | 27,640,633 | 159 |
I'm running a Kubernetes cluster on AWS using kops. I've mounted an EBS volume onto a container and it is visible from my application but it's read only because my application does not run as root. How can I mount a PersistentVolumeClaim as a user other than root? The VolumeMount does not seem to have any options to co... | The Pod Security Context supports setting an fsGroup, which allows you to set the group ID that owns the volume, and thus who can write to it. The example in the docs:
apiVersion: v1
kind: Pod
metadata:
name: hello-world
spec:
containers:
# specification of the pod's containers
# ...
securityContext:
fsGr... | Kubernetes | 43,544,370 | 153 |
Dockerfile has a parameter for ENTRYPOINT and while writing Kubernetes deployment YAML file, there is a parameter in Container spec for COMMAND.
I am not able to figure out what's the difference and how each is used?
| Kubernetes provides us with multiple options on how to use these commands:
When you override the default Entrypoint and Cmd in Kubernetes .yaml file, these rules apply:
If you do not supply command or args for a Container, the defaults
defined in the Docker image are used.
If you supply only args for a Container, the ... | Kubernetes | 44,316,361 | 152 |
What is the difference between persistent volume (PV) and persistent volume claim (PVC) in Kubernetes/ Openshift by referring to documentation?
What is the difference between both in simple terms?
| From the docs
PVs are resources in the cluster. PVCs are requests for those resources and also act as claim checks to the resource.
So a persistent volume (PV) is the "physical" volume on the host machine that stores your persistent data. A persistent volume claim (PVC) is a request for the platform to create a PV fo... | Kubernetes | 48,956,049 | 148 |
I've been using K8S ConfigMap and Secret to manage our properties. My design is pretty simple, that keeps properties files in a git repo and use build server such as Thoughtworks GO to automatically deploy them to be ConfigMaps or Secrets (on choice condition) to my k8s cluster.
Currently, I found it's not really effic... | You can get YAML from the kubectl create configmap command and pipe it to kubectl apply, like this:
kubectl create configmap foo --from-file foo.properties -o yaml --dry-run=client | kubectl apply -f -
| Kubernetes | 38,216,278 | 147 |
I am new to Kubernetes and started reading through the documentation.
There often the term 'endpoint' is used but the documentation lacks an explicit definition.
What is an 'endpoint' in terms of Kubernetes? Where is it located?
I could image the 'endpoint' is some kind of access point for an individual 'node' but that... | Pods expose themselves through endpoints to a service.
It is if you will part of a pod.
Source: Services and Endpoints
| Kubernetes | 52,857,825 | 146 |
I had the below YAML for my Ingress and it worked (and continues to work):
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: test-ingress
namespace: test-layer
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- host: mylocalhost.com
http:
paths:
... | I think that this PR contains the change you're asking about.
`Ingress` and `IngressClass` resources have graduated to `networking.k8s.io/v1`. Ingress and IngressClass types in the `extensions/v1beta1` and `networking.k8s.io/v1beta1` API versions are deprecated and will no longer be served in 1.22+. Persisted objects c... | Kubernetes | 64,125,048 | 146 |
As I understand the purpose of the Kubernetes Controller is to make sure that current state is equal to the desired state. Nevertheless, Kubernetes Operator does the same job.
The list of controller in the Control-Plane:
Deployment
ReplicaSet
StatefulSet
DaemonSet
etc
From the Google Search, I found out that there ar... | I believe the term "kubernetes operator" was introduced by the CoreOS people here
An Operator is an application-specific controller that extends the Kubernetes API to create, configure and manage instances of complex stateful applications on behalf of a Kubernetes user. It builds upon the basic Kubernetes resource and... | Kubernetes | 47,848,258 | 145 |
I have my deployment.yaml file within the templates directory of Helm charts with several environment variables for the container I will be running using Helm.
Now I want to be able to pull the environment variables locally from whatever machine the helm is ran so I can hide the secrets that way.
How do I pass this in ... | You can export the variable and use it while running helm install.
Before that, you have to modify your chart so that the value can be set while installation.
Skip this part, if you already know, how to setup template fields.
As you don't want to expose the data, so it's better to have it saved as secret in kubernete... | Kubernetes | 49,928,819 | 145 |
I used to be able to curl
https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1beta3/namespaces/default/
as my base URL, but in kubernetes 0.18.0 it gives me "unauthorized". The strange thing is that if I used the external IP address of the API machine (http://172.17.8.101:8080/api/v1beta3/namespaces/... | In the official documentation I found this:
https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#accessing-the-api-from-a-pod
Apparently I was missing a security token that I didn't need in a previous version of Kubernetes. From that, I devised what I think is a simpler solution than running a p... | Kubernetes | 30,690,186 | 141 |
While deploying mojaloop, Kubernetes responds with the following errors:
Error: validation failed: [unable to recognize "": no matches for kind
"Deployment" in version "apps/v1beta2", unable to recognize "": no
matches for kind "Deployment" in version "extensions/v1beta1", unable
to recognize "": no matches for kind "... | In Kubernetes 1.16 some apis have been changed.
You can check which apis support current Kubernetes object using
$ kubectl api-resources | grep deployment
deployments deploy apps true Deployment
This means that only apiVersion with apps is correct for Dep... | Kubernetes | 58,481,850 | 141 |
Kubernetes assigns an IP address for each container, but how can I acquire the IP address from a container in the Pod? I couldn't find the way from documentations.
Edit: I'm going to run Aerospike cluster in Kubernetes. and the config files need its own IP address. And I'm attempting to use confd to set the hostname. I... | The simplest answer is to ensure that your pod or replication controller yaml/json files add the pod IP as an environment variable by adding the config block defined below. (the block below additionally makes the name and namespace available to the pod)
env:
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPat... | Kubernetes | 30,746,888 | 140 |
Background:
Currently we're using Docker and Docker Compose for our services. We have externalized the configuration for different environments into files that define environment variables read by the application. For example a prod.env file:
ENV_VAR_ONE=Something Prod
ENV_VAR_TWO=Something else Prod
and a test.env fi... | You can populate a container's environment variables through the use of Secrets or ConfigMaps. Use Secrets when the data you are working with is sensitive (e.g. passwords), and ConfigMaps when it is not.
In your Pod definition specify that the container should pull values from a Secret:
apiVersion: v1
kind: Pod
metadat... | Kubernetes | 33,478,555 | 136 |
What is detached mode in the docker world? I read this article
Link, but it does not explain exactly what detached mode mean.
| You can start a docker container in detached mode with a -d option. So the container starts up and run in background. That means, you start up the container and could use the console after startup for other commands.
The opposite of detached mode is foreground mode. That is the default mode, when -d option is not used.... | Kubernetes | 34,029,680 | 136 |
I have followed the helloword tutorial on http://kubernetes.io/docs/hellonode/.
When I run:
kubectl run hello-node --image=gcr.io/PROJECT_ID/hello-node:v1 --port=8080
I get:
The connection to the server localhost:8080 was refused - did you specify the right host or port?
Why does the command line try to connect to t... | The issue is that your kubeconfig is not right.
To auto-generate it run:
gcloud container clusters get-credentials "CLUSTER NAME"
This worked for me.
| Kubernetes | 36,650,642 | 136 |
I was playing around in minikube and installed the wrong version of istio. I ran:
kubectl apply -f install/kubernetes/istio-demo-auth.yaml
instead of:
kubectl apply -f install/kubernetes/istio-demo.yaml
I figured I would just undo it and install the right one.
But I cannot seem to find an unapply command.
How do I u... | One way would be kubectl delete -f <filename> but it implies few things:
The resources were first created. It simply removes all of those, if you really want to "revert to the previous state" I'm not sure there are built-in tools in Kubernetes to do that (so you really would restore from a backup, if you have one)
The... | Kubernetes | 57,683,206 | 136 |
For example, a deployment yaml file:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: guestbook
spec:
replicas: 2
template:
metadata:
labels:
app: guestbook
spec:
container:
- name: guestbook
image: {{Here want to read value from config file out... | You can also use envsubst when deploying.
e.g.
cat app/deployment.yaml | envsubst | kubectl apply ...
It will replace all variables in the file with their values.
We are successfully using this approach on our CI when deploying to multiple environments, also to inject the CI_TAG etc into the deployments.
| Kubernetes | 48,296,082 | 133 |
I am using
kubectl scale --replicas=0 -f deployment.yaml
to stop all my running pods. Please let me know if there are better ways to bring down all running pods to Zero keeping configuration, deployments etc.. intact, so that I can scale up later as required.
| You are doing the correct action; traditionally the scale verb is applied just to the resource name, as in kubectl scale deploy my-awesome-deployment --replicas=0, which removes the need to always point at the specific file that describes that deployment, but there's nothing wrong (that I know of) with using the file i... | Kubernetes | 47,572,597 | 130 |
Kubernetes seems to be all about deploying containers to a cloud of clusters. What it doesn't seem to touch is development and staging environments (or such).
During development you want to be as close as possible to production environment with some important changes:
Deployed locally (or at least somewhere where you ... | Update (2016-07-15)
With the release of Kubernetes 1.3, Minikube is now the recommended way to run Kubernetes on your local machine for development.
You can run Kubernetes locally via Docker. Once you have a node running you can launch a pod that has a simple web server and mounts a volume from your host machine. Whe... | Kubernetes | 29,746,926 | 126 |
I'm looking for a way to tell (from within a script) when a Kubernetes Job has completed. I want to then get the logs out of the containers and perform cleanup.
What would be a good way to do this? Would the best way be to run kubectl describe job <job_name> and grep for 1 Succeeded or something of the sort?
| Since version 1.11, you can do:
kubectl wait --for=condition=complete job/myjob
and you can also set a timeout:
kubectl wait --for=condition=complete --timeout=30s job/myjob
| Kubernetes | 44,686,568 | 125 |
kubectl logs -f pod shows all logs from the beginning and it becomes a problem when the log is huge and we have to wait for a few minutes to get the last log. Its become more worst when connecting remotely. Is there a way that we can tail the logs for the last 100 lines of logs and follow them?
| In a cluster best practices are to gather all logs in a single point through an aggregator and analyze them with a dedicated tool. For that reason in K8S, log command is quite basic.
Anyway kubectl logs -h shows some options useful for you:
# Display only the most recent 20 lines of output in pod nginx
kubectl logs --t... | Kubernetes | 51,835,066 | 125 |
I'm able to connect to an ElastiCache Redis instance in a VPC from EC2 instances. But I would like to know if there is a way to connect to an ElastiCache Redis node outside of Amazon EC2 instances, such as from my local dev setup or VPS instances provided by other vendors.
Currently when trying from my local set up:
re... | SSH port forwarding should do the trick. Try running this from you client.
ssh -f -N -L 6379:<your redis node endpoint>:6379 <your EC2 node that you use to connect to redis>
Then from your client
redis-cli -h 127.0.0.1 -p 6379
Please note that default port for redis is 6379 not 6739. And also make sure you allow the ... | Kubernetes | 21,917,661 | 121 |
I am trying to get the namespace of the currently used Kubernetes context using kubectl.
I know there is a command kubectl config get-contexts but I see that it cannot output in json/yaml. The only script I've come with is this:
kubectl config get-contexts --no-headers | grep '*' | grep -Eo '\S+$'
| This works if you have a namespace selected in your context:
kubectl config view --minify -o jsonpath='{..namespace}'
Also, kube-ps1 can be used to display your current context and namespace in your shell prompt.
| Kubernetes | 55,853,977 | 121 |
While I explored yaml definitions of Kubernetes templates, I stumbled across different definitions of sizes. First I thought it's about the apiVersions but they are the same. So what is the difference there? Which are right when both are the same?
storage: 5G and storage: 5Gi
volumeClaimTemplates:
- metadata:
n... | From Kubernetes source:
Limits and requests for memory are measured in bytes. You can express
memory as a plain integer or as a fixed-point integer using one of
these suffixes: E, P, T, G, M, K. You can also use the power-of-two
equivalents: Ei, Pi, Ti, Gi, Mi, Ki. For example, the following
represent roughly the same... | Kubernetes | 50,804,915 | 117 |
When I try to install a chart with helm:
helm install stable/nginx-ingress --name my-nginx
I get the error:
Error: unknown flag: --name
But I see the above command format in many documentations.
Version:
version.BuildInfo{Version:"v3.0.0-beta.3",
GitCommit:"5cb923eecbe80d1ad76399aee234717c11931d9a",
GitTreeS... | In Helm v3, the release name is now mandatory as part of the commmand, see helm install --help:
Usage:
helm install [NAME] [CHART] [flags]
Your command should be:
helm install my-nginx stable/nginx-ingress
Furthermore, Helm will not auto-generate names for releases anymore. If you want the "old behavior", you ca... | Kubernetes | 57,961,162 | 117 |
Is there a simple kubectl command to take a kubeconfig file (that contains a cluster+context+user) and merge it into the ~/.kube/config file as an additional context?
| Do this:
export KUBECONFIG=~/.kube/config:~/someotherconfig
kubectl config view --flatten
You can then pipe that out to a new file if needed.
| Kubernetes | 46,184,125 | 116 |
I have installed helm 2.6.2 on the kubernetes 8 cluster. helm init worked fine. but when I run helm list it giving this error.
helm list
Error: configmaps is forbidden: User "system:serviceaccount:kube-system:default" cannot list configmaps in the namespace "kube-system"
How to fix this RABC error message?
| Once these commands:
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}... | Kubernetes | 46,672,523 | 116 |
I created the following persistent volume by calling
kubectl create -f nameOfTheFileContainingTheFollowingContent.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-monitoring-static-content
spec:
capacity:
storage: 100Mi
accessModes:
- ReadWriteOnce
hostPath:
path: "/some/path"
---
api... | This happens when persistent volume is protected. You should be able to cross verify this:
Command:
kubectl describe pvc PVC_NAME | grep Finalizers
Output:
Finalizers: [kubernetes.io/pvc-protection]
You can fix this by setting finalizers to null using kubectl patch:
kubectl patch pvc PVC_NAME -p '{"metadata":{"fin... | Kubernetes | 51,358,856 | 116 |
I am trying to understand Stateful Sets. How does their use differ from the use of "stateless" Pods with Persistent Volumes? That is, assuming that a "normal" Pod may lay claim to persistent storage, what obvious thing am I missing that requires this new construct (with ordered start/stop and so on)?
| Yes, a regular pod can use a persistent volume. However, sometimes you have multiple pods that logically form a "group". Examples of this would be database replicas, ZooKeeper hosts, Kafka nodes, etc. In all of these cases there's a bunch of servers and they work together and talk to each other. What's special about th... | Kubernetes | 41,732,819 | 115 |
The docs are great about explaining how to set a taint on a node, or remove one. And I can use kubectl describe node to get a verbose description of one node, including its taints. But what if I've forgotten the name of the taint I created, or which nodes I set it on? Can I list all of my nodes, with any taints that ex... |
kubectl get nodes -o json | jq '.items[].spec'
which will give the complete spec with node name, or:
kubectl get nodes -o json | jq '.items[].spec.taints'
will produce the list of the taints per each node
| Kubernetes | 43,379,415 | 114 |
I have a local kubernetes cluster on my local docker desktop.
This is how my kubernetes service looks like when I do a kubectl describe service
Name: helloworldsvc
Namespace: test
Labels: app=helloworldsvc
Annotations: kubectl.kubernetes.io/last-applied-configuration:
... | URL of service is in the below format:
<service-name>.<namespace>.svc.cluster.local:<service-port>
In your case it is:
helloworldsvc.test.svc.cluster.local:9111
| Kubernetes | 59,558,303 | 113 |
As stated in the title, is it possible to find out a K8s cluster name from the API? I looked around the API and could not find it.
| kubectl config current-context does the trick (it outputs little bit more, like project name, region, etc., but it should give you the answer you need).
| Kubernetes | 38,242,062 | 111 |
I am evaluating Kubernetes as a platform for our new application. For now, it looks all very exciting! However, I’m running into a problem: I’m hosting my cluster on GCE and I need some mechanism to share storage between two pods - the continous integration server and my application server. What’s the best way for doi... | Firstly, do you really need multiple readers / writers?
From my experience of Kubernetes / micro-service architecture (MSA), the issue is often more related to your design pattern. One of the fundamental design patterns with MSA is the proper encapsulation of services, and this includes the data owned by each service.
... | Kubernetes | 31,693,529 | 110 |
I'm looking for some pros and cons of whether to go with Marathon and Chronos, Docker Swarm or Kubernetes when running Docker containers on DC/OS.
For example, when is it better to use Marathon/Chronos than Kubernetes and vice versa?
Right now I'm mostly into experimenting but hopefully we'll start using one of these... | I'll try to break down the unique aspects of each container orchestration framework on Mesos.
Use Docker Swarm if:
You want to use the familiar Docker API to launch Docker containers on Mesos.
Swarm may eventually provide an API to talk to Kubernetes (even K8s-Mesos) too.
See: http://www.techrepublic.com/article/docke... | Kubernetes | 29,198,840 | 109 |
My question is simple.
How to execute a bash command in the pod? I want to do everything with a single bash command.
[root@master ~]# kubectl exec -it --namespace="tools" mongo-pod --bash -c "mongo"
Error: unknown flag: --bash
So, the command is simply ignored.
[root@master ~]# kubectl exec -it --namespace="tools" mon... | The double dash symbol "--" is used to separate the command you want to run inside the container from the kubectl arguments.
So the correct way is:
kubectl exec -it --namespace=tools mongo-pod -- bash -c "mongo"
You forgot a space between "--" and "bash".
To execute multiple commands you may want:
to create a script ... | Kubernetes | 51,247,619 | 109 |
I need to configure Ingress Nginx on azure k8s, and my question is if is possible to have ingress configured in one namespace et. ingress-nginx and some serivces in other namespace eg. resources?
My files looks like so:
# ingress-nginx.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-ingress... | I would like to simplify the answer a bit for those who are relatively new to Kubernetes and its ingress options. There are 2 separate things that need to be present for ingress(es) to work:
Ingress Controller: a separate DaemonSet (a controller which runs on all nodes, including any future ones) along with a Service ... | Kubernetes | 59,844,622 | 109 |
I am new to kubernetes. I have an issue in the pods. When I run the command
kubectl get pods
Result:
NAME READY STATUS RESTARTS AGE
mysql-apim-db-1viwg 1/1 Running 1 20h
mysql-govdb-qioee 1/1 Running 1 20h
mysql-userdb-l8q... | In case of not having the yaml file:
kubectl get pod PODNAME -n NAMESPACE -o yaml | kubectl replace --force -f -
| Kubernetes | 40,259,178 | 108 |
Let say I want to find the kubelet and apiserver version of my k8s master(s), what's the best way to do it?
I am aware of the following commands:
kubectl cluster-info
which only shows the endpoints.
kubectl get nodes; kubectl describe node <node>;
which shows very detail information but only the nodes and not master.... | kubectl version also shows the apiserver version. For example, this is the output when I run it:
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.4", GitCommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", GitTreeState:"clean"}
Server Version: version.Info{Major:"1", Minor:"2", GitVer... | Kubernetes | 38,230,452 | 107 |
Can I have multiple values.yaml files in a Helm chart?
Something like mychart/templates/internalValues.yaml, mychart/templates/customSettings.yaml, etc?
Accessing properties in a values.yaml file can be done by {{ .Values.property1 }}.
How would I reference the properties in these custom values.yaml files?
| Yes, it's possible to have multiple values files with Helm. Just use the --values flag (or -f).
Example:
helm install ./path --values ./internalValues.yaml --values ./customSettings.yaml
You can also pass in a single value using --set.
Example:
helm install ./path --set username=ADMIN --set password=${PASSWORD}
Fro... | Kubernetes | 51,097,553 | 105 |
I am building the Dockerfile for python script which will run in minikube windows 10 system below is my Dockerfile
Building the docker using the below command
docker build -t python-helloworld .
and loading that in minikube docker demon
docker save python-helloworld | (eval $(minikube docker-env) && docker load)
Docker... | This can also happen when your host machine has a different architecture from your guest container image.
E.g. running an arm container on a host with x86-64 architecture
| Kubernetes | 58,298,774 | 101 |
I have an admin.conf file containing info about a cluster, so that the following command works fine:
kubectl --kubeconfig ./admin.conf get nodes
How can I config kubectl to use the cluster, user and authentication from this file as default in one command? I only see separate set-cluster, set-credentials, set-context, ... | The best way I've found was to use an environment variable:
export KUBECONFIG=/path/to/admin.conf
| Kubernetes | 40,447,295 | 100 |
In kubernetes there is a rolling update (automatically without downtime) but there is not a rolling restart, at least i could not find. We have to change deployment yaml. Is there a way to make rolling "restart", preferably without changing deployment yaml?
| Before kubernetes 1.15 the answer is no. But there is a workaround of patching deployment spec with a dummy annotation:
kubectl patch deployment web -p \
"{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"date\":\"`date +'%s'`\"}}}}}"
As of kubernetes 1.15 you can use:
kubectl rollout restart deployment your... | Kubernetes | 57,559,357 | 99 |
In minikube, how to expose a service using nodeport ?
For example, I start a kubernetes cluster using the following command and create and expose a port like this:
$ minikube start
$ kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080
$ kubectl expose deployment hello-minikube --type=... | I am not exactly sure what you are asking as it seems you already know about the minikube service <SERVICE_NAME> --url command which will give you a url where you can access the service. In order to open the exposed service, the minikube service <SERVICE_NAME> command can be used:
$ kubectl run hello-minikube --image=g... | Kubernetes | 40,767,164 | 98 |
Any idea to view the log files of a crashed pod in kubernetes?
My pod is listing it's state as "CrashLoopBackOff" after started the replicationController. I search the available docs and couldn't find any.
| Assuming that your pod still exists:
kubectl logs <podname> --previous
$ kubectl logs -h
-p, --previous[=false]: If true, print the logs for the previous instance of the container in a pod if it exists.
| Kubernetes | 34,084,689 | 97 |
In the Kubernetes minikube tutorial there is this command to use Minikube Docker daemon :
$ eval $(minikube docker-env)
What exactly does this command do, that is, what exactly does minikube docker-env mean?
| The command minikube docker-env returns a set of Bash environment variable exports to configure your local environment to re-use the Docker daemon inside the Minikube instance.
Passing this output through eval causes bash to evaluate these exports and put them into effect.
You can review the specific commands which wil... | Kubernetes | 52,310,599 | 96 |
I initialized the master node and add 2 worker nodes, but only master and one of the worker node show up when I run the following command:
kubectl get nodes
also, both these nodes are in 'Not Ready' state.
What are the steps should I take to understand what the problem could be?
I can ping all the nodes from each of... | First, describe nodes and see if it reports anything:
$ kubectl describe nodes
Look for conditions, capacity and allocatable:
Conditions:
Type Status
---- ------
OutOfDisk False
MemoryPressure False
DiskPressure False
Ready True
Capacity:
cpu: 2
... | Kubernetes | 47,107,117 | 95 |
I've lost the original 'kubeadm join' command when I previously ran kubeadm init.
How can I retrieve this value again?
| kubeadm token create --print-join-command
| Kubernetes | 51,126,164 | 95 |
Some characteristics of Apache Parquet are:
Self-describing
Columnar format
Language-independent
In comparison to Apache Avro, Sequence Files, RC File etc. I want an overview of the formats. I have already read : How Impala Works with Hadoop File Formats. It gives some insights on the formats but I would like to know... | I think the main difference I can describe relates to record oriented vs. column oriented formats. Record oriented formats are what we're all used to -- text files, delimited formats like CSV, TSV. AVRO is slightly cooler than those because it can change schema over time, e.g. adding or removing columns from a record... | Avro | 36,822,224 | 209 |
All of these provide binary serialization, RPC frameworks and IDL. I'm interested in key differences between them and characteristics (performance, ease of use, programming languages support).
If you know any other similar technologies, please mention it in an answer.
| ASN.1 is an ISO/ISE standard. It has a very readable source language and a variety of back-ends, both binary and human-readable. Being an international standard (and an old one at that!) the source language is a bit kitchen-sinkish (in about the same way that the Atlantic Ocean is a bit wet) but it is extremely well-... | Avro | 4,633,611 | 133 |
I am running into some issues setting up default values for Avro fields. I have a simple schema as given below:
data.avsc:
{
"namespace":"test",
"type":"record",
"name":"Data",
"fields":[
{ "name": "id", "type": [ "long", "null" ] },
{ "name": "value", "type": [ "string", "null" ] },
{ "name": "raw", "t... | The default value of a union corresponds to the first schema of the union (Source). Your union is defined as ["long", "null"] therefor the default value must be a long number. null is not a long number that is why you are getting an error.
If you still want to define null as a default value then put null schema first, ... | Avro | 22,938,124 | 75 |
Does anyone knows how to create Avro schema which contains list of objects of some class?
I want my generated classes to look like below :
class Child {
String name;
}
class Parent {
list<Child> children;
}
For this, I have written part of schema file but do not know how to tell Avro to create list of objects... | You need to use array type for creating the list.
Following is the updated schema that handles your usecase.
{
"name": "Parent",
"type":"record",
"fields":[
{
"name":"children",
"type":{
"type": "array",
"items":{
"name":"... | Avro | 25,076,786 | 54 |
Working on a pet project (cassandra, spark, hadoop, kafka) I need a data serialization framework. Checking out the common three frameworks - namely Thrift, Avro and Protocolbuffers - I noticed most of them seem to be dead-alive having 2 minor releases a year at most.
This leaves me with two assumptions:
They are as co... | Protocol Buffers is a very mature framework, having been first introduced nearly 15 years ago at Google. It's certainly not dead: Nearly every service inside Google uses it. But after so much usage, there probably isn't much that needs to change at this point. In fact, they did a major release (3.0) this year, but the ... | Avro | 40,968,303 | 53 |
I need to use the Confluent kafka-avro-serializer Maven artifact. From the official guide I should add this repository to my Maven pom
<repository>
<id>confluent</id>
<url>http://packages.confluent.io/maven/</url>
</repository>
The problem is that the URL http://packages.confluent.io/maven/ seems to not work at th... | Needs to add confluent repositories in pom.xml
Please add below lines in the pom.xml
<repositories>
<repository>
<id>confluent</id>
<url>https://packages.confluent.io/maven/</url>
</repository>
</repositories>
| Avro | 43,488,853 | 52 |
I'm trying to get Python to parse Avro schemas such as the following...
from avro import schema
mySchema = """
{
"name": "person",
"type": "record",
"fields": [
{"name": "firstname", "type": "string"},
{"name": "lastname", "type": "string"},
{
"name": "address",
... | According to other sources on the web I would rewrite your second address definition:
mySchema = """
{
"name": "person",
"type": "record",
"fields": [
{"name": "firstname", "type": "string"},
{"name": "lastname", "type": "string"},
{
"name": "address",
"type":... | Avro | 11,764,287 | 45 |
I wrote one Avro schema in which some of the fields ** need to be ** of type String but Avro has generated those fields of type CharSequence.
I am not able to find any way to tell Avro to make those fields of type String.
I tried to use
"fields": [
{
"name":"startTime",
"type":"string",
"a... | If you want all you string fields be instances of java.lang.String then you only have to configure the compiler:
java -jar /path/to/avro-tools-1.7.7.jar compile -string schema
or if you are using the Maven plugin
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.7... | Avro | 25,118,727 | 36 |
Apache Avro provides a compact, fast, binary data format, rich data structure for serialization. However, it requires user to define a schema (in JSON) for object which need to be serialized.
In some case, this can not be possible (e.g: the class of that Java object has some members whose types are external java class... | Take a look at the Java reflection API.
Getting a schema looks like:
Schema schema = ReflectData.get().getSchema(T);
See the example from Doug on another question for a working example.
Credits of this answer belong to Sean Busby.
| Avro | 22,954,315 | 35 |
I'm trying to validate a JSON file using an Avro schema and write the corresponding Avro file. First, I've defined the following Avro schema named user.avsc:
{"namespace": "example.avro",
"type": "record",
"name": "user",
"fields": [
{"name": "name", "type": "string"},
{"name": "favorite_number", "type": ... | According to the explanation by Doug Cutting,
Avro's JSON encoding requires that non-null union values be tagged
with their intended type. This is because unions like
["bytes","string"] and ["int","long"] are ambiguous in JSON, the first
are both encoded as JSON strings, while the second are both encoded as
... | Avro | 27,485,580 | 35 |
I'm using a Kafka Source in Spark Structured Streaming to receive Confluent encoded Avro records. I intend to use Confluent Schema Registry, but the integration with spark structured streaming seems to be impossible.
I have seen this question, but unable to get it working with the Confluent Schema Registry. Reading Av... | It took me a couple months of reading source code and testing things out. In a nutshell, Spark can only handle String and Binary serialization. You must manually deserialize the data. In spark, create the confluent rest service object to get the schema. Convert the schema string in the response object into an Avro sche... | Avro | 48,882,723 | 33 |
Is it possible to write an Avro schema/IDL that will generate a Java class that either extends a base class or implements an interface?
It seems like the generated Java class extends the org.apache.avro.specific.SpecificRecordBase. So, the implements might be the way to go. But, I don't know if this is possible.
I hav... | I found a better way to solve this problem. Looking at the Schema generation source in Avro, I figured out that internally the class generation logic uses Velocity schemas to generate the classes.
I modified the record.vm template to also implement my specific interface. There is a way to specify the location of veloc... | Avro | 20,864,470 | 32 |
I'm trying to use Avro for messages being read from/written to Kafka. Does anyone have an example of using the Avro binary encoder to encode/decode data that will be put on a message queue?
I need the Avro part more than the Kafka part. Or, perhaps I should look at a different solution? Basically, I'm trying to find a... | This is a basic example. I have not tried it with multiple partitions/topics.
//Sample producer code
import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.io.*;
import org.apache.avro.specific.SpecificDatumReader;
import org.apach... | Avro | 8,298,308 | 30 |
I'm a noob to Kafka and Avro. So i have been trying to get the Producer/Consumer running. So far i have been able to produce and consume simple Bytes and Strings, using the following :
Configuration for the Producer :
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
pro... | Note first: KafkaAvroSerializer is not provided in vanilla apache kafka - it is provided by Confluent Platform. (https://www.confluent.io/), as part of its open source components (http://docs.confluent.io/current/platform.html#confluent-schema-registry)
Rapid answer: no, if you use KafkaAvroSerializer, you will need a ... | Avro | 45,635,726 | 30 |
How do you extract first the schema and then the data from an avro file in Java? Identical to this question except in java.
I've seen examples of how to get the schema from an avsc file but not an avro file. What direction should I be looking in?
Schema schema = new Schema.Parser().parse(
new File("/home/Hadoop/Avr... | If you want know the schema of a Avro file without having to generate the corresponding classes or care about which class the file belongs to, you can use the GenericDatumReader:
DatumReader<GenericRecord> datumReader = new GenericDatumReader<>();
DataFileReader<GenericRecord> dataFileReader = new DataFileReader<>(new ... | Avro | 45,496,786 | 28 |
Avro serialization is popular with Hadoop users but examples are so hard to find.
Can anyone help me with this sample code? I'm mostly interested in using the Reflect API to read/write into files and to use the Union and Null annotations.
public class Reflect {
public class Packet {
int cost;
@Nul... | Here's a version of the above program that works.
This also uses compression on the file.
import java.io.File;
import org.apache.avro.Schema;
import org.apache.avro.file.DataFileWriter;
import org.apache.avro.file.DataFileReader;
import org.apache.avro.file.CodecFactory;
import org.apache.avro.io.DatumWriter;
import or... | Avro | 11,866,466 | 27 |
In one of our projects we are using Kafka with AVRO to transfer data across applications. Data is added to an AVRO object and object is binary encoded to write to Kafka. We use binary encoding as it is generally mentioned as a minimal representation compared to other formats.
The data is usually a JSON string and when ... |
If binary encoding compresses data?
Yes and no, it depends on your data.
According to avro binary encoding, yes for it only stores the schema once for each .avro file, regardless how many datas in that file, hence save some space w/o storing JSON's key name many times. And avro serialization do a bit compression wit... | Avro | 26,711,256 | 25 |
I want to use Avro to serialize the data for my Kafka messages and would like to use it with an Avro schema repository so I don't have to include the schema with every message.
Using Avro with Kafka seems like a popular thing to do, and lots of blogs / Stack Overflow questions / usergroups etc reference sending the Sch... | The schema id is actually encoded in the avro message itself. Take a look at this to see how encoders/decoders are implemented.
In general what's happening when you send an Avro message to Kafka:
The encoder gets the schema from the object to be encoded.
Encoder asks the schema registry for an id for this schema. If t... | Avro | 31,204,201 | 25 |
Latest Avro compiler (1.8.2) generates java sources for dates logical types with Joda-Time based implementations. How can I configure Avro compiler to produce sources that used Java 8 date-time API?
| Currently (avro 1.8.2) this is not possible. It's hardcoded to generate Joda date/time classes.
The current master branch has switched to Java 8 and there is an open issue (with Pull Request) to add the ability to generate classes with java.time.* types.
I have no idea on any kind of release schedule for whatever is c... | Avro | 45,712,231 | 25 |
I am trying to convert a Json string into a generic Java Object, with an Avro Schema.
Below is my code.
String json = "{\"foo\": 30.1, \"bar\": 60.2}";
String schemaLines = "{\"type\":\"record\",\"name\":\"FooBar\",\"namespace\":\"com.foo.bar\",\"fields\":[{\"name\":\"foo\",\"type\":[\"null\",\"double\"],\"default\":nu... | For anyone who uses Avro - 1.8.2, JsonDecoder is not directly instantiable outside the package org.apache.avro.io now. You can use DecoderFactory for it as shown in the following code:
String schemaStr = "<some json schema>";
String genericRecordStr = "<some json record>";
Schema.Parser schemaParser = new Schema.Parser... | Avro | 27,559,543 | 24 |
ZigZag requires a lot of overhead to write/read numbers. Actually I was stunned to see that it doesn't just write int/long values as they are, but does a lot of additional scrambling. There's even a loop involved:
https://github.com/mardambey/mypipe/blob/master/avro/lang/java/avro/src/main/java/org/apache/avro/io/Direc... | It is a variable length 7-bit encoding. The first byte of the encoded value has it high bit set to 0, subsequent bytes have it at 1. Which is the way the decoder can tell how many bytes were used to encode the value. Byte order is always little-endian, regardless of the machine architecture.
It is an encoding tric... | Avro | 33,935,266 | 22 |
I am trying to use Confluent kafka-avro-console-consumer, but how to pass parameters for Schema Registry to it?
| Just a guess at what you are looking for...
kafka-avro-console-consumer --topic topicX --bootstrap-server kafka:9092 \
--property schema.registry.url="http://schema-registry:8081"
No, you cannot specify a schema version. The ID is consumed directly from the Avro data in the topic. The subject name is mapped to t... | Avro | 49,927,747 | 22 |
I like to use the same record type in an Avro schema multiple times. Consider this schema definition
{
"type": "record",
"name": "OrderBook",
"namespace": "my.types",
"doc": "Test order update",
"fields": [
{
"name": "bids",
"type": {
"type": "array",... | It's not well documented, but Avro allows you to reference previously defined names by using the full namespace for the name that is being referenced. In your case, the following code would result in only one class being generated, referenced by each array. It also DRYs up the schema nicely.
{
"type": "record",
... | Avro | 48,100,575 | 21 |
I'm dealing with server logs which are JSON format, and I want to store my logs on AWS S3 in Parquet format(and Parquet requires an Avro schema). First, all logs have a common set of fields, second, all logs have a lot of optional fields which are not in the common set.
For example, the follwoing are three logs:
{ "ip"... | The map type is a "complex" type in avro terminology. The below snippet works:
{
"namespace": "example.avro",
"type": "record",
"name": "Log",
"fields": [
{"name": "ip", "type": "string"},
{"name": "timestamp", "type": "string"},
{"name": "message", "type": "string"},
{"name": "additional", "ty... | Avro | 32,642,154 | 20 |
I get an error when running kafka-mongodb-source-connect
I was trying to run connect-standalone with connect-avro-standalone.properties and MongoSourceConnector.properties so that Connect write data which is written in MongoDB to Kafka topic.
This is what I wanted to do
bin/connect-standalone etc/schema-registry/connec... | MongoDB change streams option is available only in replica sets setup. However, you can update your standalone installation to a single node replica set by following the below steps.
Locate the mongodb.conf file and add the replica set details
Add the following replica set details to mongodb.conf file
replication:
... | Avro | 59,571,945 | 20 |
I can't find a way to deserialize an Apache Avro file with C#. The Avro file is a file generated by the Archive feature in Microsoft Azure Event Hubs.
With Java I can use Avro Tools from Apache to convert the file to JSON:
java -jar avro-tools-1.8.1.jar tojson --pretty inputfile > output.json
Using NuGet package Micro... | I was able to get full data access working using dynamic. Here's the code for accessing the raw body data, which is stored as an array of bytes. In my case, those bytes contain UTF8-encoded JSON, but of course it depends on how you initially created your EventData instances that you published to the Event Hub:
using (v... | Avro | 39,846,833 | 19 |
I am receiving from a remote server Kafka Avro messages in Python (using the consumer of Confluent Kafka Python library), that represent clickstream data with json dictionaries with fields like user agent, location, url, etc. Here is what a message looks like:
b'\x01\x00\x00\xde\x9e\xa8\xd5\x8fW\xec\x9a\xa8\xd5\x8fW\x1... | If you use Confluent Schema Registry and want to deserialize avro messages, just add message_bytes.seek(5) to the decode function, since Confluent adds 5 extra bytes before the typical avro-formatted data.
def decode(msg_value):
message_bytes = io.BytesIO(msg_value)
message_bytes.seek(5)
decoder = BinaryDe... | Avro | 44,407,780 | 19 |
I'm actually trying to serialize objects containing dates with Avro, and the deserialized date doesn't match the expected value (tested with avro 1.7.2 and 1.7.1). Here's the class I'm serializing :
import java.text.SimpleDateFormat;
import java.util.Date;
public class Dummy {
private Date date;
private Simple... | Avro 1.8 now has a date "logicalType", which annotates int. For example:
{"name": "date", "type": "int", "logicalType": "date"}
Quoting the spec:
A date logical type annotates an Avro int, where the int stores the
number of days from the unix epoch, 1 January 1970 (ISO calendar).
| Avro | 13,255,589 | 18 |
When attempting to write avro, I get the following error:
org.apache.spark.SparkException: Job aborted due to stage failure: Task 7 in stage 35.0 failed 1 times, most recent failure: Lost task 7.0 in stage 35.0 (TID 110, localhost): java.lang.ClassCastException: java.util.HashMap cannot be cast to org.apache.avro.mapre... | It looks like this isn't supported at the moment. You are now trying to use the java map as an Avro Record and covert it to a Java map again. That's why you get the error the error about the java hashmap.
There is a pull request from staslos to add the Avro output format, see link for the pull request and the example.... | Avro | 29,619,081 | 18 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.