go-sdk

command module
v0.0.0-...-dbc04a5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

README

go-sdk

Using Alibaba Could Go SDK with RRSA Auth.

Usage

  1. Enable RRSA:
export CLUSTER_ID=<cluster_id>
ack-ram-tool rrsa enable --cluster-id "${CLUSTER_ID}"
  1. Install ack-pod-identity-webhook:
ack-ram-tool rrsa install-helper-addon --cluster-id "${CLUSTER_ID}"
  1. Create an RAM Policy:
aliyun ram CreatePolicy --PolicyName cs-describe-clusters --PolicyDocument '{
  "Version": "1",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "cs:DescribeClusters",
        "cs:GetClusters"
      ],
      "Resource": [
        "*"
      ],
      "Condition": {}
    }
  ]
}'
  1. Associate an RAM Role to the service account and attach the policy to the role:
ack-ram-tool rrsa associate-role --cluster-id "${CLUSTER_ID}" \
    --namespace rrsa-demo-golang-sdk \
    --service-account demo-sa \
    --role-name test-rrsa-demo \
    --create-role-if-not-exist \
    --attach-custom-policy cs-describe-clusters
  1. Deploy demo job:
ack-ram-tool credential-plugin get-kubeconfig --cluster-id "${CLUSTER_ID}" > kubeconfig
kubectl --kubeconfig ./kubeconfig apply -f deploy.yaml
  1. Get logs:
kubectl --kubeconfig ./kubeconfig -n rrsa-demo-golang-sdk wait --for=condition=complete job/demo --timeout=240s
kubectl --kubeconfig ./kubeconfig -n rrsa-demo-golang-sdk logs job/demo

Outputs:

test open api sdk use rrsa oidc token

cluster id: c4db8***, cluster name: foo***
cluster id: cc20c***, cluster name: bar***

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL