|
2 | 2 |
|
3 | 3 | module Main where
|
4 | 4 |
|
5 |
| -import Data.Function ((&)) |
6 |
| -import Kubernetes.Client (defaultTLSClientParams, |
7 |
| - disableServerCertValidation, |
8 |
| - disableServerNameValidation, |
9 |
| - disableValidateAuthMethods, |
10 |
| - loadPEMCerts, newManager, |
11 |
| - setCAStore, setClientCert, |
12 |
| - setMasterURI, setTokenAuth) |
13 |
| -import Kubernetes.OpenAPI (Accept (..), MimeJSON (..), |
14 |
| - dispatchMime, newConfig) |
| 5 | +import Control.Concurrent.STM (atomically, newTVar) |
| 6 | +import Data.Function ((&)) |
| 7 | +import Kubernetes.Client (KubeConfigSource (..), defaultTLSClientParams, |
| 8 | + disableServerCertValidation, |
| 9 | + disableServerNameValidation, |
| 10 | + disableValidateAuthMethods, kubeClient, |
| 11 | + loadPEMCerts, newManager, setCAStore, |
| 12 | + setClientCert, setMasterURI, setTokenAuth) |
| 13 | +import Kubernetes.OpenAPI (Accept (..), MimeJSON (..), dispatchMime, |
| 14 | + newConfig) |
| 15 | +import Network.TLS (credentialLoadX509) |
| 16 | + |
| 17 | +import qualified Data.Map as Map |
15 | 18 | import qualified Kubernetes.OpenAPI.API.CoreV1 as CoreV1
|
16 |
| -import Network.TLS (credentialLoadX509) |
17 | 19 |
|
18 | 20 | example :: IO ()
|
19 | 21 | example = do
|
@@ -42,5 +44,25 @@ example = do
|
42 | 44 | (CoreV1.listPodForAllNamespaces (Accept MimeJSON))
|
43 | 45 | >>= print
|
44 | 46 |
|
| 47 | +exampleWithKubeConfig :: IO () |
| 48 | +exampleWithKubeConfig = do |
| 49 | + oidcCache <- atomically $ newTVar $ Map.fromList [] |
| 50 | + (mgr, kcfg) <- kubeClient oidcCache $ KubeConfigFile "/path/to/kubeconfig" |
| 51 | + dispatchMime |
| 52 | + mgr |
| 53 | + kcfg |
| 54 | + (CoreV1.listPodForAllNamespaces (Accept MimeJSON)) |
| 55 | + >>= print |
| 56 | + |
| 57 | +exampleWithInClusterConfig :: IO () |
| 58 | +exampleWithInClusterConfig = do |
| 59 | + oidcCache <- atomically $ newTVar $ Map.fromList [] |
| 60 | + (mgr, kcfg) <- kubeClient oidcCache KubeConfigCluster |
| 61 | + dispatchMime |
| 62 | + mgr |
| 63 | + kcfg |
| 64 | + (CoreV1.listPodForAllNamespaces (Accept MimeJSON)) |
| 65 | + >>= print |
| 66 | + |
45 | 67 | main :: IO ()
|
46 | 68 | main = return ()
|
0 commit comments