kuberneteslib 0.5.2 kuberneteslib: ^0.5.2 copied to clipboard
A library that implements the Kubernetes API natively. It is written using the direct specs and currently covers most of the V1 Core, Apps, and Batch resources.
example/kuberneteslib_example.dart
import 'package:kuberneteslib/kuberneteslib.dart';
Future<void> main() async {
//Initialize cluster configuration from default kubectl config
final config = Config.fromYaml('<kubernetes config yaml>');
// Initialize an auth
final auth = ClusterAuth.fromConfig(config!);
await auth.ensureInitialization();
//List all pods in the 'default' namespace
final pods = await Resource.list(resourceKind: 'pod', namespace: 'default');
//Print pod information
for (final pod in pods) {
print('Pod: ${pod.metadata!.name}');
print('Metadata: ${pod.metadata}');
print('Spec: ${pod.spec}');
print('Status: ${pod.status}');
print('---');
}
}