|
1 | | -# otc-cli |
| 1 | +# OTC CLI |
| 2 | + |
2 | 3 | A command-line interface tool for Open Telekom Cloud (OTC) that provides seamless authentication and resource management with federated Single Sign-On (SSO) support. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- 🔐 **Federated Authentication** - Login via OIDC/Keycloak SSO or IAM credentials |
| 8 | +- ⚡ **Temporary Credentials** - Generate 24-hour AWS-compatible credentials |
| 9 | +- 🔄 **Token Caching** - Automatic token management and refresh |
| 10 | +- 📦 **Resource Management** - List and manage OTC resources |
| 11 | +- 🌐 **Multi-Project Support** - Work with multiple OTC projects |
| 12 | +- 🚀 **CCE Integration** - Get kubeconfig for Kubernetes clusters |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +### From Source |
| 17 | + |
| 18 | +```bash |
| 19 | +git clone https://github.com/abdo-farag/otc-cli.git |
| 20 | +cd otc-cli |
| 21 | +go build -o otc-cli cmd/otc-cli/main.go |
| 22 | +sudo mv otc-cli /usr/local/bin/ |
| 23 | +``` |
| 24 | + |
| 25 | +### Using Go Install |
| 26 | + |
| 27 | +```bash |
| 28 | +go install github.com/abdo-farag/otc-cli@latest |
| 29 | +``` |
| 30 | + |
| 31 | +## Quick Start |
| 32 | + |
| 33 | +### Option 1: Login with Federated SSO (OIDC/Keycloak) |
| 34 | + |
| 35 | +1. **Configure environment variables:** |
| 36 | + |
| 37 | +```bash |
| 38 | +# OIDC/Keycloak Configuration |
| 39 | +export IDP_URL="https://your-keycloak.com/realms/YourRealm" |
| 40 | +export IDP_CLIENT_ID="otc-client" |
| 41 | +export IDP_CLIENT_SECRET="your-client-secret" # Optional, for confidential clients |
| 42 | +export IDP_PROVIDER_NAME="YourSSO" |
| 43 | + |
| 44 | +# OTC Configuration |
| 45 | +export OS_DOMAIN_NAME="OTC00000000001000001234" |
| 46 | +export OS_REGION="eu-de" |
| 47 | +``` |
| 48 | + |
| 49 | +2. **Login:** |
| 50 | + |
| 51 | +```bash |
| 52 | +otc-cli login |
| 53 | +``` |
| 54 | + |
| 55 | +This will open your browser for SSO authentication. After successful login, credentials are saved to `otc-credentials.sh`. |
| 56 | + |
| 57 | +3. **Load credentials:** |
| 58 | + |
| 59 | +```bash |
| 60 | +source otc-credentials.sh |
| 61 | +``` |
| 62 | + |
| 63 | +### Option 2: Login with IAM Credentials |
| 64 | + |
| 65 | +1. **Configure environment variables:** |
| 66 | + |
| 67 | +```bash |
| 68 | +export OS_USERNAME="your-username" |
| 69 | +export OS_PASSWORD="your-password" |
| 70 | +export OS_DOMAIN_NAME="OTC00000000001000001234" |
| 71 | +export OS_REGION="eu-de" |
| 72 | +``` |
| 73 | + |
| 74 | +2. **Login:** |
| 75 | + |
| 76 | +```bash |
| 77 | +otc-cli login --iam |
| 78 | +``` |
| 79 | + |
| 80 | +3. **Load credentials:** |
| 81 | + |
| 82 | +```bash |
| 83 | +source otc-credentials.sh |
| 84 | +``` |
| 85 | + |
| 86 | +## Basic Usage |
| 87 | + |
| 88 | +### List Resources |
| 89 | + |
| 90 | +```bash |
| 91 | +# List all projects |
| 92 | +otc-cli list projects |
| 93 | + |
| 94 | +# List servers/instances |
| 95 | +otc-cli list servers |
| 96 | + |
| 97 | +# List servers in specific project |
| 98 | +otc-cli list servers -p "Production" |
| 99 | + |
| 100 | +# List VPCs |
| 101 | +otc-cli list vpcs |
| 102 | + |
| 103 | +# List subnets |
| 104 | +otc-cli list subnets |
| 105 | + |
| 106 | +# List volumes |
| 107 | +otc-cli list volumes |
| 108 | + |
| 109 | +# List CCE clusters |
| 110 | +otc-cli list cce |
| 111 | +``` |
| 112 | + |
| 113 | +### Get Kubeconfig |
| 114 | + |
| 115 | +```bash |
| 116 | +# Get kubeconfig for CCE cluster |
| 117 | +otc-cli get kubeconfig -c cluster-name |
| 118 | + |
| 119 | +# Save to specific file |
| 120 | +otc-cli get kubeconfig -c cluster-id -o ~/.kube/otc-config |
| 121 | +``` |
| 122 | + |
| 123 | +### Logout |
| 124 | + |
| 125 | +Clear cached credentials: |
| 126 | + |
| 127 | +```bash |
| 128 | +otc-cli logout |
| 129 | +``` |
| 130 | + |
| 131 | +## Configuration |
| 132 | + |
| 133 | +### Keycloak OIDC Client Setup |
| 134 | + |
| 135 | +If using federated SSO, configure your Keycloak client: |
| 136 | + |
| 137 | +1. **Create OIDC Client** in Keycloak Admin Console |
| 138 | +2. **Client Settings:** |
| 139 | + - Client Protocol: `openid-connect` |
| 140 | + - Access Type: `public` or `confidential` |
| 141 | + - Valid Redirect URIs: `http://localhost:9197/oidc/auth` |
| 142 | + - Web Origins: `http://localhost:9197` |
| 143 | +3. **Required Scopes:** `openid`, `email`, `profile`, `roles`, `groups`, `offline_access` |
| 144 | + |
| 145 | +### Environment Variables |
| 146 | + |
| 147 | +| Variable | Description | Required | Default | |
| 148 | +|----------|-------------|----------|---------| |
| 149 | +| `IDP_URL` | Keycloak/OIDC provider URL | For SSO | - | |
| 150 | +| `IDP_CLIENT_ID` | OIDC client ID | For SSO | - | |
| 151 | +| `IDP_CLIENT_SECRET` | OIDC client secret | No | - | |
| 152 | +| `IDP_PROVIDER_NAME` | Identity provider name in OTC | For SSO | - | |
| 153 | +| `OS_USERNAME` | IAM username | For IAM | - | |
| 154 | +| `OS_PASSWORD` | IAM password | For IAM | - | |
| 155 | +| `OS_DOMAIN_NAME` | OTC domain name | Yes | - | |
| 156 | +| `OS_REGION` | OTC region | No | `eu-de` | |
| 157 | + |
| 158 | +## Documentation |
| 159 | + |
| 160 | +For advanced usage, detailed examples, and troubleshooting, see the [complete documentation](otc-cli.md). |
| 161 | + |
| 162 | +Topics covered in the advanced docs: |
| 163 | +- Working with multiple projects |
| 164 | +- JSON output and scripting |
| 165 | +- Integration with AWS CLI, Terraform, and boto3 |
| 166 | +- Detailed troubleshooting guide |
| 167 | +- Authentication flow diagrams |
| 168 | +- CI/CD integration |
| 169 | + |
| 170 | +## Quick Troubleshooting |
| 171 | + |
| 172 | +### "Could not find OIDC configuration" error |
| 173 | + |
| 174 | +- Verify `IDP_PROVIDER_NAME` matches the Identity Provider name in OTC IAM |
| 175 | +- Check that federated identity is properly configured in OTC Console |
| 176 | + |
| 177 | +### "Project not found" error |
| 178 | + |
| 179 | +List available projects first: |
| 180 | +```bash |
| 181 | +otc-cli list projects |
| 182 | +``` |
| 183 | + |
| 184 | +### Browser doesn't open |
| 185 | + |
| 186 | +Use no-browser mode: |
| 187 | +```bash |
| 188 | +otc-cli login --no-browser |
| 189 | +``` |
| 190 | + |
| 191 | +For more detailed troubleshooting, see [otc-cli.md](otc-cli.md). |
| 192 | + |
| 193 | +## Contributing |
| 194 | + |
| 195 | +Contributions are welcome! Please feel free to submit a Pull Request. |
| 196 | + |
| 197 | +1. Fork the repository |
| 198 | +2. Create your feature branch (`git checkout -b feature/amazing-feature`) |
| 199 | +3. Commit your changes (`git commit -m 'Add amazing feature'`) |
| 200 | +4. Push to the branch (`git push origin feature/amazing-feature`) |
| 201 | +5. Open a Pull Request |
| 202 | + |
| 203 | +## License |
| 204 | + |
| 205 | +MIT License - see [LICENSE](LICENSE) file for details |
| 206 | + |
| 207 | +## Links |
| 208 | + |
| 209 | +- **Documentation:** [otc-cli.md](otc-cli.md) |
| 210 | +- **Issues:** [GitHub Issues](https://github.com/abdo-farag/otc-cli/issues) |
| 211 | +- **Repository:** [github.com/abdo-farag/otc-cli](https://github.com/abdo-farag/otc-cli) |
| 212 | + |
| 213 | +## Related Documentation |
| 214 | + |
| 215 | +- **Keycloak Documentation:** [https://www.keycloak.org/documentation](https://www.keycloak.org/documentation) |
| 216 | + - [OIDC Client Configuration](https://www.keycloak.org/docs/latest/server_admin/#_oidc_clients) |
| 217 | + - [Identity Brokering](https://www.keycloak.org/docs/latest/server_admin/#_identity_broker) |
| 218 | +- **Open Telekom Cloud Documentation:** [https://docs.otc.t-systems.com/](https://docs.otc.t-systems.com/) |
| 219 | + - [Identity and Access Management (IAM)](https://docs.otc.t-systems.com/identity-access-management/umn/service_overview/what_is_iam.html) |
| 220 | + - [IAM Federated Identity Authentication](https://docs.otc.t-systems.com/identity-access-management/umn/user_guide/federated_identity_authentication/index.html) |
| 221 | + - [API Reference](https://docs.otc.t-systems.com/api/api-ref.html) |
| 222 | +- **Gopher Telekom Cloud SDK:** [https://github.com/opentelekomcloud/gophertelekomcloud](https://github.com/opentelekomcloud/gophertelekomcloud) |
| 223 | + - Go SDK for Open Telekom Cloud (this project uses it internally) |
| 224 | + |
| 225 | +--- |
| 226 | + |
| 227 | +**Note:** This is an unofficial tool and is not supported by T-Systems or Deutsche Telekom. |
0 commit comments