Skip to content

Commit 299d137

Browse files
committed
merging hand-written code into one package
1 parent e084d0c commit 299d137

File tree

15 files changed

+86
-127
lines changed

15 files changed

+86
-127
lines changed

kubeconfig/package.yaml

Lines changed: 0 additions & 23 deletions
This file was deleted.

kubernetes-client-helper/.gitignore

Lines changed: 0 additions & 9 deletions
This file was deleted.

kubernetes-client-helper/README.md

Lines changed: 0 additions & 52 deletions
This file was deleted.

kubernetes-client-helper/package.yaml

Lines changed: 0 additions & 21 deletions
This file was deleted.

kubeconfig/.gitignore renamed to kubernetes-openapi-client/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ dist-newstyle
66
cabal.project.local
77
.cabal-sandbox
88
cabal.sandbox.config
9-
*.cabal
9+
*.cabal

kubernetes-watch/README.md renamed to kubernetes-openapi-client/README.md

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,49 @@
1-
# kubernetes-watch-client
2-
3-
Client for streaming events from watch enabled endpoints.
1+
# kubernetes-openapi-client
42

53
## Example
4+
5+
```haskell
6+
{-# LANGUAGE OverloadedStrings #-}
7+
8+
module Main where
9+
10+
import Data.Function ((&))
11+
import qualified Kubernetes.API.CoreV1
12+
import Kubernetes.Client (dispatchMime)
13+
import Kubernetes.ClientHelper
14+
import Kubernetes.Core (newConfig)
15+
import Kubernetes.MimeTypes (Accept (..), MimeJSON (..))
16+
import Network.TLS (credentialLoadX509)
17+
18+
main :: IO ()
19+
main = do
20+
-- We need to first create a Kubernetes.Core.KubernetesConfig and a Network.HTTP.Client.Manager.
21+
-- Currently we need to construct these objects manually. Work is underway to construct these
22+
-- objects automatically from a kubeconfig file. See https://github.com/kubernetes-client/haskell/issues/2.
23+
kcfg <-
24+
newConfig
25+
& fmap (setMasterURI "https://mycluster.example.com") -- fill in master URI
26+
& fmap (setTokenAuth "mytoken") -- if using token auth
27+
& fmap disableValidateAuthMethods -- if using client cert auth
28+
myCAStore <- loadPEMCerts "/path/to/ca.crt" -- if using custom CA certs
29+
myCert <- -- if using client cert
30+
credentialLoadX509 "/path/to/client.crt" "/path/to/client.key"
31+
>>= either error return
32+
tlsParams <-
33+
defaultTLSClientParams
34+
& fmap disableServerNameValidation -- if master address is specified as an IP address
35+
& fmap disableServerCertValidation -- if you don't want to validate the server cert at all (insecure)
36+
& fmap (setCAStore myCAStore) -- if using custom CA certs
37+
& fmap (setClientCert myCert) -- if using client cert
38+
manager <- newManager tlsParams
39+
dispatchMime
40+
manager
41+
kcfg
42+
(Kubernetes.API.CoreV1.listPodForAllNamespaces (Accept MimeJSON))
43+
>>= print
44+
```
45+
46+
## Watch Example
647
Following is a simple example which
748
just streams to stdout. First some setup - this assumes kubernetes is accessible
849
at http://localhost:8001, e.g. after running `kubectl proxy`:
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: kubernetes-openapi-client
2+
version: 0.1.0.0
3+
description: |
4+
This package contains functions for working with kubeconfig files.
5+
6+
Usage of kubeconfig files are described at https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/
7+
library:
8+
source-dirs: src
9+
tests:
10+
spec:
11+
main: Spec.hs
12+
source-dirs: test
13+
dependencies:
14+
- kubernetes-openapi-client
15+
- hspec
16+
- yaml
17+
extra-source-files:
18+
- test/testdata/*
19+
dependencies:
20+
- base >=4.7 && <5.0
21+
- bytestring >=0.10.0 && <0.11
22+
- aeson >=1.0 && <2.0
23+
- connection
24+
- containers
25+
- data-default-class
26+
- http-client >=0.5 && <0.6
27+
- http-client-tls
28+
- kubernetes-openapi-client-gen == 0.1.0.0
29+
- microlens >= 0.4.3 && <0.5
30+
- mtl >=2.2.1
31+
- pem
32+
- safe-exceptions <0.2
33+
- streaming-bytestring >= 0.1.5 && < 0.2.0
34+
- text >=0.11 && <1.3
35+
- tls
36+
- x509
37+
- x509-system
38+
- x509-store
39+
- x509-validation

0 commit comments

Comments
 (0)