<p>I have a running jenkins pod and i am trying to execute following commands:</p>

<pre><code>sudo kubectl --kubeconfig /opt/jenkins_home/admin.conf apply -f /opt/jenkins_home/ab-kubernetes/ab-back.yml
</code></pre>

<p>It is giving following error:</p>

<p><strong>Error from server (NotFound): the server could not find the requested resource</strong></p>

<p>What cound go wrong here?</p>

<p><code>ab-back.yml</code> file</p>

<pre><code>---
apiVersion: v1
kind: Service
metadata:
  name: dg-back-svc
spec:
  selector:
    app: dg-core-backend-d
  type: NodePort
  ports:
    - name: http
      protocol: TCP
      port: 8081
      nodePort: 30003
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: dg-core-backend-d
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: dg-core-backend-d
    spec:
      containers:
      - name: dg-core-java
        image: ab/dg-springboot-java:1.0
        imagePullPolicy: IfNotPresent
        command: ["sh"]
        args: ["-c", "/root/post-deployment.sh"]
        ports:
        - containerPort: 8081
        # livenessProbe:
        #   httpGet:
        #     path: /
        #     port: 8080
        env:
        - name: SPRING_PROFILES_ACTIVE
          value: xxx
</code></pre>

<p><strong>UPDATE:</strong></p>

<p><code>kubectl version</code> is as follows :</p>

<pre><code>Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.0", GitCommit:"91e7b4fd31fcd3d5f436da26c980becec37ceefe", GitTreeState:"clean", BuildDate:"2018-06-27T20:17:28Z", GoVersion:"go1.10.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.0", GitCommit:"fff5156092b56e6bd60fff75aad4dc9de6b6ef37", GitTreeState:"clean", BuildDate:"2017-03-28T16:24:30Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}
</code></pre>

<p>On applying logs as <code>--v=4</code>,<code>kubectl apply</code> is working and giving logs as follows :</p>

<pre><code>I0702 11:40:17.721604    1601 merged_client_builder.go:159] Using in-cluster namespace
I0702 11:40:17.734648    1601 decoder.go:224] decoding stream as YAML
service/dg-back-svc created
deployment.extensions/dg-core-backend-d created
</code></pre>

<p>but <code>kubectl create</code> is giving error as :</p>

<pre><code>I0702 11:41:12.265490    1631 helpers.go:201] server response object: [{
  "metadata": {},
  "status": "Failure",
  "message": "the server could not find the requested resource",
  "reason": "NotFound",
  "details": {
    "causes": [
      {
        "reason": "UnexpectedServerResponse",
        "message": "unknown"
      }
    ]
  },
  "code": 404
}]
</code></pre>

<p>Also on doing <code>kubectl get pods --v=10</code>,it is giving log as :</p>

<pre><code>Response Body: {
  "metadata": {},
  "status": "Failure",
  "message": "only the following media types are accepted: application/json, application/yaml, application/vnd.kubernetes.protobuf",
  "reason": "NotAcceptable",
  "code": 406
}
I0702 12:34:27.542564    2514 request.go:1099] body was not decodable (unable to check for Status): Object 'Kind' is missing in '{
  "metadata": {},
  "status": "Failure",
  "message": "only the following media types are accepted: application/json, application/yaml, application/vnd.kubernetes.protobuf",
  "reason": "NotAcceptable",
  "code": 406
}'
No resources found.
I0702 12:34:27.542813    2514 helpers.go:201] server response object: [{
  "metadata": {},
  "status": "Failure",
  "message": "unknown (get pods)",
  "reason": "NotAcceptable",
  "details": {
    "kind": "pods",
    "causes": [
      {
        "reason": "UnexpectedServerResponse",
        "message": "unknown"
      }
    ]
  },
  "code": 406
}]
</code></pre>

Arshanvit
<p>The problem is in versions, try to use the old version of the client or upgrade the server. kubectl supports one version forward and backward skew:</p>

<p>From <a href="https://github.com/kubernetes/community/blob/master/contributors/design-proposals/release/versioning.md#supported-releases-and-component-skew" rel="nofollow noreferrer">documentation</a></p>

<blockquote>
  <p>a client should be skewed no more than one minor version from the
  master, but may lead the master by up to one minor version. For
  example, a v1.3 master should work with v1.1, v1.2, and v1.3 nodes,
  and should work with v1.2, v1.3, and v1.4 clients.</p>
</blockquote>
