Can't pull image from private registry - docker

I have this error (rpc error: code = NotFound desc = failed to pull and unpack image "docker.io/registryName/projectName:latest": failed to unpack image on snapshotter overlayfs: unexpected media type text/html) when trying to deploy with the following deployment.yml file
apiVersion: apps/v1
kind: Deployment
metadata:
name: <projectName>-deployment
namespace: <projectNamespace>
spec:
selector:
matchLabels:
app: <projectname>
replicas: 1
template:
metadata:
labels:
app: <projectName>
spec:
containers:
- name: private-reg
image: <registry>/<projectName>:latest
ports:
- containerPort: 9000
imagePullSecrets:
- name: docker-hub-cred
I can't understand what's happening because using a simple pod.yml it's working:
apiVersion: v1
kind: Pod
metadata:
name: <projectName>-pod
namespace: <projectNamespace>
spec:
containers:
- name: <projectName>
image: <registry>/<projectName>:latest
imagePullSecrets:
- name: docker-hub-cred

Related

Empty kubernetes VPA recommendations

I have the following manifest:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-rec-deployment
spec:
replicas: 2
selector:
matchLabels:
app: my-rec-deployment
template:
metadata:
labels:
app: my-rec-deployment
spec:
containers:
- name: my-rec-container
image: nginx
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: my-rec-vpa
spec:
targetRef:
apiVersion: "apps/v1"
kind: Deployment
name: my-rec-deployment
updatePolicy:
updateMode: "Off"
When I run it with (kubectl get vpa my-rec-vpa --output yaml), I have the following output for recco:
status:
conditions:
- lastTransitionTime: "2022-05-17T11:10:32Z"
status: "False"
type: RecommendationProvided
recommendation: {}
What is the problem with recommendations?

Issue with Jenkins Deployment File: Unknown resource kind: Deployment

I'm struggling to figure out what the solution might be, so I thought to ask here. I'm trying to use the code below to deploy a Jenkins pod to Kubernetes, but it fails with a Unknown resource kind: Deployment error:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: jenkins-deployment
spec:
replicas: 1
selector:
matchLabels:
app: jenkins
template:
metadata:
labels:
app: jenkins
spec:
containers:
- name: jenkins
image: jenkins/jenkins:lts-alpine
ports:
- name: http-port
containerPort: 8080
volumeMounts:
- name: jenkins-home
mountPath: /var/jenkins_home
volumes:
- name: jenkins-home
emptyDir: {}
The output of kubectl api-versions is:
admissionregistration.k8s.io/v1
admissionregistration.k8s.io/v1beta1
apiextensions.k8s.io/v1
apiextensions.k8s.io/v1beta1
apiregistration.k8s.io/v1
apiregistration.k8s.io/v1beta1
apps/v1
authentication.k8s.io/v1
authentication.k8s.io/v1beta1
authorization.k8s.io/v1
authorization.k8s.io/v1beta1
autoscaling/v1
autoscaling/v2beta1
autoscaling/v2beta2
batch/v1
batch/v1beta1
certificates.k8s.io/v1beta1
coordination.k8s.io/v1
coordination.k8s.io/v1beta1
discovery.k8s.io/v1beta1
events.k8s.io/v1beta1
extensions/v1beta1
networking.k8s.io/v1
networking.k8s.io/v1beta1
node.k8s.io/v1beta1
policy/v1beta1
rbac.authorization.k8s.io/v1
rbac.authorization.k8s.io/v1beta1
scheduling.k8s.io/v1
scheduling.k8s.io/v1beta1
storage.k8s.io/v1
storage.k8s.io/v1beta1
v1
Does anyone know what the problem might be?
If this is an indentation issue, I'm failing to see it.
It seems the apiVersion is deprecated. You can simply convert to current apiVersion and apply.
$ kubectl convert -f jenkins-dep.yml
kubectl convert is DEPRECATED and will be removed in a future version.
In order to convert, kubectl apply the object to the cluster, then kubectl get at the desired version.
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: jenkins
name: jenkins-deployment
spec:
progressDeadlineSeconds: 2147483647
replicas: 1
revisionHistoryLimit: 2147483647
selector:
matchLabels:
app: jenkins
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: jenkins
spec:
containers:
- image: jenkins/jenkins:lts-alpine
imagePullPolicy: IfNotPresent
name: jenkins
ports:
- containerPort: 8080
name: http-port
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/jenkins_home
name: jenkins-home
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: jenkins-home
status: {}
$ kubectl convert -f jenkins-dep.yml -oyaml > jenkins-dep-latest.yml
Change the apiVersion from extensions/v1beta1 to apps/v1 and use kubectl version to check if the kubectl client and kube API Server version is matching and not too old.

Virtual Kubelet with AKS

I followed the doc here
When I tried to create a virtual service for Windows, I get error:
The Deployment "nanoserver-iis" is invalid: spec.template.metadata.labels: Invalid value: map[string]string{"app":"nanoserver-iis"}: selector does not match template labels
kubectl get nodes
`NAME STATUS ROLES AGE
VERSION
aks-agentpool-27326293-0 Ready agent 15m
v1.11.3
virtual-kubelet-aci-connector-windows-westeurope Ready agent 9s
v1.11.2`
virtual-kubelet-windows.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nanoserver-iis
spec:
replicas: 1
selector:
matchLabels:
app: aci-helloworld
template:
metadata:
labels:
app: nanoserver-iis
spec:
containers:
- name: nanoserver-iis
image: microsoft/iis:nanoserver
ports:
- containerPort: 80
nodeSelector:
kubernetes.io/hostname: virtual-kubelet-aci-connector-windows-westeurope
tolerations:
- key: virtual-kubelet.io/provider
operator: Equal
value: azure
effect: NoSchedule
Try updating the deployment definition with the following. There is an inconsistency in the YAML definition where labels don't match. Labels in the matchLabeles field and labels in the metadata field need to match. In the deployment definition, they are set to different values aci-helloworld and nanoserver-iis respectively.
apiVersion: apps/v1
kind: Deployment
metadata:
name: nanoserver-iis
spec:
replicas: 1
selector:
matchLabels:
app: nanoserver-iis
template:
metadata:
labels:
app: nanoserver-iis
spec:
containers:
- name: nanoserver-iis
image: microsoft/iis:nanoserver
ports:
- containerPort: 80
nodeSelector:
kubernetes.io/hostname: virtual-kubelet-aci-connector-windows-westeurope
tolerations:
- key: virtual-kubelet.io/provider
operator: Equal
value: azure
effect: NoSchedule

Kubernetes- 403 forbidden issue

I am deploying java service from VSTS to Docker and then to Kubernetes. I am able to push and run image successfully from ACR. After pushing into Kubernetes, I am not able to browse the service from Kubernetes.
apiVersion: apps/v1
kind : Deployment
metadata :
name: xservice
labels:
app: xserviceapi
spec:
template:
metadata:
labels:
app: xserviceapi
type : Back-end
spec:
containers:
- name: xservice
image : acr.azurecr.io/xservice:latest
imagePullPolicy: Always
ports:
- containerPort: 80
imagePullSecrets:
- name: regcre
replicas: 1
selector:
matchLabels:
app: xserviceapi
---
apiVersion: v1
kind: Service
metadata:
name: xservice
spec:
type: LoadBalancer
ports:
- port: 80
selector:
app: xserviceapi
As #OnurYarta┼či mentioned, you should be able to reach your service using 40.68.134.174 IP address.

k8s doesn't download docker container

when i run my command to apply the modification or just to create ( pods, service, Deployments)
kubectl apply -f hello-kubernetes-oliver.yml
I dont have an error.
But when i do docker ps to see if the container was downloaded from my private registery. i've nothing :(
If i run the command docker-all.attanea.net/hello_world:latestit download the container.
i dont understand why it doesn't download my container with the first command ?
you will find below my hello-kubernetes-oliver.yml
apiVersion: v1
kind: Service
metadata:
name: hello-kubernetes-oliver
spec:
type: NodePort
ports:
- port: 80
targetPort: 8080
selector:
app: hello-kubernetes-oliver
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: hello-kubernetes-oliver
spec:
replicas: 1
template:
metadata:
labels:
app: hello-kubernetes-oliver
spec:
containers:
- name: hello-kubernetes-oliver
image: private-registery.net/hello_world:latest
ports:
- containerPort: 80
In order to download Images from the Private registry, You need to create a Secret which is used in the Deployment Manifest.
kubectl create secret docker-registry regcred --docker-server= --docker-username="your-name" --docker-password="your-pword" --docker-email="your-email"
https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-in-the-cluster-that-holds-your-authorization-token
regcred is the name of the secret resources.
Then you attach regcred secret in your deployment file
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: hello-kubernetes-oliver
spec:
replicas: 1
template:
metadata:
labels:
app: hello-kubernetes-oliver
spec:
containers:
- name: hello-kubernetes-oliver
image: private-registery.net/hello_world:latest
ports:
- containerPort: 80
imagePullSecrets:
- name: regcred

Resources