Trying to use linkerd inject to annotate a cronjob yaml and it returns "!! no supported object found"
Create a cronjob yaml, apply it, then:
kubectl get cronjobs.batch mssql-backup -o yaml | linkerd inject -
(apologies for the debugging code in the sample)
$ kubectl get cronjobs.batch mssql-backup -o yaml | linkerd inject -
apiVersion: batch/v1beta1
kind: CronJob
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"batch/v1beta1","kind":"CronJob","metadata":{"annotations":{},"name":"mssql-backup","namespace":"se"},"spec":{"concurrencyPolicy":"Forbid","failedJobsHistoryLimit":1,"jobTemplate":{"spec":{"template":{"spec":{"containers":[{"args":["echo \"hello world\"; /opt/mssql-tools/bin/sqlcmd -S server -U sa -P password -I -Q \"EXEC sp_msForEachDB 'PRINT ''?'' ';\" | while read dbname; do echo \"*** Backing up $dbname ***\"; /opt/mssql-tools/bin/sqlcmd -S server -U sa -P password -I -Q \"BACKUP DATABASE master TO DISK='/mssql-backup/backup/$dbname/$dbname-$(date +%Y-%m-%d.%s).bak' WITH STATS, COMPRESSION;\" ; done; echo \"*** End of $dbname backup ***\"; echo \"\"; sleep 60; echo \" *** NORMAL TERMINATION *** \";"],"command":["bash","-c"],"image":"microsoft/mssql-tools","name":"mssql-backup"}],"nodeSelector":{"kubernetes.io/os":"linux"},"restartPolicy":"Never","securityContext":{"fsGroup":0,"runAsUser":0}}}}},"schedule":"*/5 * * * *","successfulJobsHistoryLimit":3}}
creationTimestamp: "2019-10-23T20:03:48Z"
name: mssql-backup
namespace: se
resourceVersion: "2061027"
selfLink: /apis/batch/v1beta1/namespaces/se/cronjobs/mssql-backup
uid: 399f4b60-f5d0-11e9-a92d-72a7270cd27e
spec:
concurrencyPolicy: Forbid
failedJobsHistoryLimit: 1
jobTemplate:
metadata:
creationTimestamp: null
spec:
template:
metadata:
creationTimestamp: null
spec:
containers:
- args:
- echo "hello world"; /opt/mssql-tools/bin/sqlcmd -S server
-U sa -P password -I -Q "EXEC sp_msForEachDB
'PRINT ''?'' ';" | while read dbname; do echo "*** Backing up $dbname
***"; /opt/mssql-tools/bin/sqlcmd -S server -U sa -P password
-I -Q "BACKUP DATABASE master TO DISK='/mssql-backup/backup/$dbname/$dbname-$(date
+%Y-%m-%d.%s).bak' WITH STATS, COMPRESSION;" ; done; echo "*** End of
$dbname backup ***"; echo ""; sleep 60; echo " *** NORMAL TERMINATION
*** ";
command:
- bash
- -c
image: microsoft/mssql-tools
imagePullPolicy: Always
name: mssql-backup
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
nodeSelector:
kubernetes.io/os: linux
restartPolicy: Never
schedulerName: default-scheduler
securityContext:
fsGroup: 0
runAsUser: 0
terminationGracePeriodSeconds: 30
schedule: '*/5 * * * *'
successfulJobsHistoryLimit: 3
suspend: false
status:
active:
- apiVersion: batch/v1
kind: Job
name: mssql-backup-1571861700
namespace: se
resourceVersion: "2061025"
uid: f8bae702-f5d1-11e9-a92d-72a7270cd27e
lastScheduleTime: "2019-10-23T20:15:00Z"
---
โผ no supported objects found
cronjob "mssql-backup" skipped
linkerd check output```$ linkerd check
โ can initialize the client
โ can query the Kubernetes API
โ is running the minimum Kubernetes API version
โ is running the minimum kubectl version
โ control plane Namespace exists
โ control plane ClusterRoles exist
โ control plane ClusterRoleBindings exist
โ control plane ServiceAccounts exist
โ control plane CustomResourceDefinitions exist
โ control plane MutatingWebhookConfigurations exist
โ control plane ValidatingWebhookConfigurations exist
โ control plane PodSecurityPolicies exist
โ 'linkerd-config' config map exists
โ heartbeat ServiceAccount exist
โ control plane replica sets are ready
โ no unschedulable pods
โ controller pod is running
โ can initialize the client
โ can query the control plane API
โ control plane pods are ready
โ control plane self-check
โ [kubernetes] control plane can talk to Kubernetes
โ [prometheus] control plane can talk to Prometheus
โ no invalid service profiles
โ can determine the latest version
โ cli is up-to-date
โ control plane is up-to-date
โ control plane and cli versions match
Status check results are โ
$ linkerd version
Client version: stable-2.6.0
Server version: stable-2.6.0
```
This is actually to add the annotation to end up "disable"ing the auto-proxy-inject until we figure out how to ask the sidecar to exit when the main container is done.
As of now, linkerd inject does not support configs of Kind Cronjob.
As per the cases listed under method conf.getFreshWorkloadObj() (at pkg/inject/inject.go), nil is returned while trying to parse a config of type Cronjob.
Neither is method conf.parse() setup to process a config of this kind.
Once we have that, such a config can be unmarshalled to *ResourceConfig, have the annotations appended and marshalled back to yaml.
This would however be a cool feature to have.
@grampelberg @ihcsim WDYT?
This feature is very similar to https://github.com/linkerd/linkerd2/pull/3607
@mayankshah1607 go for it!
Hi guys,
Do you mind if I take care of this one? I was doing it as part of #3614
cc @scottcarol
@tegioz Sure, go ahead! :)