examples icon indicating copy to clipboard operation
examples copied to clipboard

Example 8-1-kuard-rs.yaml does not work

Open luistrigueiros opened this issue 5 years ago • 2 comments

Trying to run the example 8-1-kuard-rs.yaml with kubectl v1.16.3 and minikube v.1.6.2 and getting validation error:

➜ kubernetes-up-and-running_examples git:(master) ✗ kubectl apply -f 8-1-kuard-rs.yaml
error: error validating "8-1-kuard-rs.yaml": error validating data: ValidationError(ReplicaSet.spec): missing required field "selector" in io.k8s.api.apps.v1.ReplicaSetSpec; if you choose to ignore these errors, turn validation off with --validate=false
➜ kubernetes-up-and-running_examples git:(master) ✗ kubectl apply -f 8-1-kuard-rs.yaml
The ReplicaSet "kuard" is invalid: spec.template.metadata.labels: Invalid value: map[string]string{"app":"kuard", "version":"2"}: `selector` does not match template `labels`
➜ kubernetes-up-and-running_examples git:(master) ✗ kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.3", GitCommit:"b3cbbae08ec52a7fc73d334838e18d17e8512749", GitTreeState:"clean", BuildDate:"2019-11-13T11:23:11Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0", GitCommit:"70132b0f130acc0bed193d9ba59dd186f0e634cf", GitTreeState:"clean", BuildDate:"2019-12-07T21:12:17Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"linux/amd64"}
➜ kubernetes-up-and-running_examples git:(master) ✗ minikube version
minikube version: v1.6.2
commit: 54f28ac5d3a815d1196cd5d57d707439ee4bb392

luistrigueiros avatar Dec 23 '19 12:12 luistrigueiros

First of all Examples in 8th chapter should contain ingress examples according to 2nd edition.

sbugalski avatar Jan 15 '20 15:01 sbugalski

It seems the newer versions of the API require a selector:

In the 2nd edition for me, kuard-rs.yaml appears in Chapter 9, so if you meant Example 9-1, try this?

---
apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: kuard
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kuard
  template:
    metadata:
      labels:
        app: kuard
        version: "2"
    spec:
      containers:
        - name: kuard
          image: "gcr.io/kuar-demo/kuard-amd64:green"

ericdorsey avatar Mar 19 '20 03:03 ericdorsey

Addressed in the following PR - https://github.com/kubernetes-up-and-running/examples/pull/28

lachie83 avatar Nov 15 '23 04:11 lachie83