Saturday, September 26, 2020

Access Weblogic log information through Elasticsearch and Kibana

Elastic

Kibana


WebLogic Logging Exporter 

 https://github.com/oracle/weblogic-logging-exporter


Install WebLogic Logging Exporter 



Copy JAR to domain
cp ~/Downloads/weblogic-logging-exporter-1.0.0.jar /app/domains/base_domain/

Start Weblogic domain
[dave@dave ~]$ cd /app/domains/base_domain/
[dave@dave base_domain]$ ./startWebLogic.sh 

Access Weblogic console via browser at
http://localhost:7001/console/
Add StarUp class In the Administration Console, navigate to "Environment" then "Startup and Shutdown classes" in the main menu. Add a new Startup class. You may choose any descriptive name and the class name must be weblogic.logging.exporter.Startup. Target the startup class to each server that you want to export logs from.
base_domain]$ more config/config.xml

  <startup-class>
    <name>StartupClass-weblogic.logging.exporter</name>
    <target>AdminServer</target>
    <class-name>weblogic.logging.exporter.Startup</class-name>
  </startup-class>

Download org.yaml:snakeyaml https://search.maven.org/artifact/org.yaml/snakeyaml/1.27/bundle
 cp ~/Downloads/snakeyaml-1.27.jar /app/domains/base_domain/

Add CLASSPATH into bin/setDomainEnv.sh
ls snakeyaml-1.27.jar 
snakeyaml-1.27.jar
[dave@dave base_domain]$ grep snake bin/setDomainEnv.sh 
export CLASSPATH=$DOMAIN_HOME/weblogic-logging-exporter-1.0.0.jar:snakeyaml-1.27.jar:$CLASSPATH

Add WebLogic Logging Exporter config file
vi config/WebLogicLoggingExporter.yaml

more   config/WebLogicLoggingExporter.yaml
publishHost:  localhost
publishPort:  9200
domainUID:  base_domain
weblogicLoggingExporterEnabled: true
weblogicLoggingIndexName:  base_domain_wls
weblogicLoggingExporterSeverity:  Notice
weblogicLoggingExporterBulkSize: 1
weblogicLoggingExporterFilters:
- filterExpression:  'severity > Warning'

Install Docker ElasticSearch https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.9.2
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.9.2


ocker pull docker.elastic.co/elasticsearch/elasticsearch:7.9.2
7.9.2: Pulling from elasticsearch/elasticsearch
f1feca467797: Pull complete 
2b669da077a4: Pull complete 
e5b4c466fc6d: Pull complete 
3b660c013f1a: Pull complete 
0e7ad1133ad1: Pull complete 
b50d6e48f432: Pull complete 
bff3705905f9: Pull complete 
9509765886ad: Pull complete 
b7f06f509306: Pull complete 
Digest: sha256:2be3302537236874fdeca184c78a49aed17d5aca0f8fc3f6192a80e93e817cb4
Status: Downloaded newer image for docker.elastic.co/elasticsearch/elasticsearch:7.9.2
docker.elastic.co/elasticsearch/elasticsearch:7.9.2

Run Docker Elastic


docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.9.2


Install Kibana https://www.elastic.co/guide/en/kibana/current/docker.html
docker pull docker.elastic.co/kibana/kibana:7.9.2
Start dev Kibana
docker run -d                           --name kibana                         -p 5601:5601                          --link elasticsearch:elasticsearch    -e "ELASTICSEARCH_URL=http://elasticsearch:9200"   docker.elastic.co/kibana/kibana:7.9.2

Docker containers
 docker ps
CONTAINER ID        IMAGE                                                 COMMAND                  CREATED             STATUS              PORTS                                            NAMES
8ba52c43304f        docker.elastic.co/kibana/kibana:7.9.2                 "/usr/local/bin/dumb…"   4 seconds ago       Up 3 seconds        0.0.0.0:5601->5601/tcp                           kibana
9fdc569676e0        docker.elastic.co/elasticsearch/elasticsearch:7.9.2   "/tini -- /usr/local…"   6 minutes ago       Up 6 minutes        0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   elasticsearch

Weblogic start log when Elastic cannot be reached
======================= Weblogic Logging Exporter Startup class called
Reading configuration from file name: /app/domains/base_domain/config/WebLogicLoggingExporter.yaml
<Sep 26, 2020 10:24:49,146 AM CEST> <Notice> <Log Management> <BEA-170027> <The server has successfully established a connection with the Domain level Diagnostic Service.> 
Config{weblogicLoggingIndexName='domain1-wls', publishHost='localhost', publishPort=9200, weblogicLoggingExporterSeverity='Notice', weblogicLoggingExporterBulkSize='1', enabled=true, weblogicLoggingExporterFilters=[FilterConfig{expression='null', servers=[]}], domainUID='domain1'}
javax.ws.rs.ProcessingException: java.net.ConnectException: Tried all: '2' addresses, but could not connect over HTTP to server: 'localhost', port: '9200'
 failed reasons:
  [0] address:'localhost/127.0.0.1',port:'9200' : java.net.ConnectException: Connection refused
  [1] address:'localhost/0:0:0:0:0:0:0:1',port:'9200' : java.net.ConnectException: Connection refused

    at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:260)
    at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:254)
    at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$0(JerseyInvocation.java:729)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:205)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:390)
    at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:728)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:421)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.put(JerseyInvocation.java:310)
    at weblogic.logging.exporter.LogExportHandler.executePutOrPostOnUrl(LogExportHandler.java:170)
    at weblogic.logging.exporter.LogExportHandler.createMappings(LogExportHandler.java:300)
    at weblogic.logging.exporter.LogExportHandler.<init>(LogExportHandler.java:56)
    at weblogic.logging.exporter.Startup.main(Startup.java:37)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at weblogic.management.deploy.classdeployment.ClassDeploymentManager.invokeMain(ClassDeploymentManager.java:449)
    at weblogic.management.deploy.classdeployment.ClassDeploymentManager.invokeClass(ClassDeploymentManager.java:359)
    at weblogic.management.deploy.classdeployment.ClassDeploymentManager.access$100(ClassDeploymentManager.java:63)
    at weblogic.management.deploy.classdeployment.ClassDeploymentManager$1.run(ClassDeploymentManager.java:286)
    at weblogic.management.deploy.classdeployment.ClassDeploymentManager$1.run(ClassDeploymentManager.java:273)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:344)
    at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)
    at weblogic.management.deploy.classdeployment.ClassDeploymentManager.invokeClassDeployment(ClassDeploymentManager.java:272)
    at weblogic.management.deploy.classdeployment.ClassDeploymentManager.invokeClassDeployments(ClassDeploymentManager.java:253)
    at weblogic.management.deploy.classdeployment.ClassDeploymentManager.runStartupsAfterAppAdminState(ClassDeploymentManager.java:215)
    at weblogic.management.deploy.classdeployment.StartupClassPrelistenService.start(StartupClassPrelistenService.java:29)
    at weblogic.server.AbstractServerService.postConstruct(AbstractServerService.java:76)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.glassfish.hk2.utilities.reflection.ReflectionHelper.invoke(ReflectionHelper.java:1268)
    at org.jvnet.hk2.internal.ClazzCreator.postConstructMe(ClazzCreator.java:309)
    at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:351)
    at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:463)
    at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:281)
    at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:65)
    at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2102)
    at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:93)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:678)
    at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:54)
    at org.jvnet.hk2.internal.ClazzCreator.resolve(ClazzCreator.java:188)
    at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:211)
    at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:334)
    at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:463)
    at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:281)
    at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:65)
    at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2102)
    at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:93)
    at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:67)
    at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.oneJob(CurrentTaskFuture.java:1213)
    at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.run(CurrentTaskFuture.java:1144)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:677)
    at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:352)
    at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:337)
    at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:57)
    at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
    at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:651)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:420)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:360)
Caused by: java.net.ConnectException: Tried all: '2' addresses, but could not connect over HTTP to server: 'localhost', port: '9200'
 failed reasons:
  [0] address:'localhost/127.0.0.1',port:'9200' : java.net.ConnectException: Connection refused
  [1] address:'localhost/0:0:0:0:0:0:0:1',port:'9200' : java.net.ConnectException: Connection refused

    at weblogic.net.http.HttpClient.openServer(HttpClient.java:408)
    at weblogic.net.http.HttpClient.openServer(HttpClient.java:511)
    at weblogic.net.http.HttpClient.New(HttpClient.java:313)
    at weblogic.net.http.HttpClient.New(HttpClient.java:292)
    at weblogic.net.http.HttpURLConnection.connect(HttpURLConnection.java:295)
    at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:685)
    at weblogic.net.http.SOAPHttpURLConnection.getInputStream(SOAPHttpURLConnection.java:42)
    at weblogic.net.http.HttpURLConnection.getResponseCode(HttpURLConnection.java:1546)
    at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:366)
    at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:258)

Weblogic good start with Elastic running in Docker
======================= Weblogic Logging Exporter Startup class called
Reading configuration from file name: /app/domains/base_domain/config/WebLogicLoggingExporter.yaml
<Sep 26, 2020 10:35:23,780 AM CEST> <Notice> <Log Management> <BEA-170027> <The server has successfully established a connection with the Domain level Diagnostic Service.> 
Config{weblogicLoggingIndexName='domain1-wls', publishHost='localhost', publishPort=9200, weblogicLoggingExporterSeverity='Notice', weblogicLoggingExporterBulkSize='1', enabled=true, weblogicLoggingExporterFilters=[FilterConfig{expression='null', servers=[]}], domainUID='domain1'}

dave@dave base_domain]$ curl "localhost:9200/_cat/indices?v"
health status index       uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   domain1-wls SQqMMWxgTCi6nhWyDSmeyg   1   1         25            0     39.6kb         39.6kb


Verify that logs were posted


Running Elasticsearch and Kibana locally for testing



Kibana



Access Kibana at http://localhost:5601/ 


 Getting
Kibana server is not ready yet



Used newest version - but there are some issues
Caused by: org.elasticsearch.index.mapper.MapperParsingException: Root mapping definition has unsupported parameters:  [doc : {properties={severity={type=keyword}, sequenceNumber={type=keyword}, subSystem={type=keyword}, level={type=keyword}, serverName={type=keyword}, messageID={type=keyword}, domainUID={type=keyword}, userId={type=keyword}, threadName={type=keyword}, machineName={type=keyword}, transactionId={type=keyword}, loggerName={type=keyword}, timestamp={type=date}}}]",
"at org.elasticsearch.index.mapper.DocumentMapperParser.checkNoRemainingFields(DocumentMapperParser.java:148) ~[elasticsearch-7.9.2.jar:7.9.2]",
"at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:136) ~[elasticsearch-7.9.2.jar:7.9.2]",
"at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:88) ~[elasticsearch-7.9.2.jar:7.9.2]",
"at org.elasticsearch.index.mapper.MapperService.internalMerge(MapperService.java:421) ~[elasticsearch-7.9.2.jar:7.9.2]",
"... 23 more"] }

Older version 6.2.2
docker run -d                       --name elasticsearch              -p 9200:9200                      -p 9300:9300                      -e "discovery.type=single-node"   docker.elastic.co/elasticsearch/elasticsearch:6.2.2
d8308574a82fc0f36e43c71846db51c7e26e567c53927c207730cde61b2512f5




docker run -d                       --name elasticsearch              -p 9200:9200                      -p 9300:9300                      -e "discovery.type=single-node"   docker.elastic.co/elasticsearch/elasticsearch:6.2.2

docker run -d                           --name kibana                         -p 5601:5601                          --link elasticsearch:elasticsearch    -e "ELASTICSEARCH_URL=http://elasticsearch:9200"   docker.elastic.co/kibana/kibana:6.2.2
ba259c96db5564c02e80116820bb78db65fd2c8919e33449d3c0ed3a6da4fb5a

Running
 docker ps
CONTAINER ID        IMAGE                                                 COMMAND                  CREATED              STATUS              PORTS                                            NAMES
ba259c96db55        docker.elastic.co/kibana/kibana:6.2.2                 "/bin/bash /usr/loca…"   34 seconds ago       Up 34 seconds       0.0.0.0:5601->5601/tcp                           kibana
d8308574a82f        docker.elastic.co/elasticsearch/elasticsearch:6.2.2   "/usr/local/bin/dock…"   About a minute ago   Up About a minute   0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   elasticsearch

Weblogic log
======================= Weblogic Logging Exporter Startup class called
Reading configuration from file name: /app/domains/base_domain/config/WebLogicLoggingExporter.yaml
<Sep 26, 2020 10:53:58,858 AM CEST> <Notice> <Log Management> <BEA-170027> <The server has successfully established a connection with the Domain level Diagnostic Service.> 
Config{weblogicLoggingIndexName='domain1-wls', publishHost='localhost', publishPort=9200, weblogicLoggingExporterSeverity='Notice', weblogicLoggingExporterBulkSize='1', enabled=true, weblogicLoggingExporterFilters=[FilterConfig{expression='null', servers=[]}], domainUID='domain1'}

Elasticsearch Kibana errors
Caused by: org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];
    at org.elasticsearch.cluster.block.ClusterBlocks.indexBlockedException(ClusterBlocks.java:182) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.support.replication.TransportReplicationAction$ReroutePhase.handleBlockExceptions(TransportReplicationAction.java:813) ~[elasticsearch-6.2.2.jar:6.2.2]

[2020-09-26T09:03:43,980][WARN ][o.e.x.m.e.l.LocalExporter] unexpected error while indexing monitoring document
org.elasticsearch.xpack.monitoring.exporter.ExportException: ClusterBlockException[blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];]
    at org.elasticsearch.xpack.monitoring.exporter.local.LocalBulk.lambda$throwExportException$2(LocalBulk.java:140) ~[?:?]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_161]
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) ~[?:1.8.0_161]
    at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[?:1.8.0_161]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[?:1.8.0_161]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[?:1.8.0_161]
    at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) ~[?:1.8.0_161]
    at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) ~[?:1.8.0_161]
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_161]
    at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) ~[?:1.8.0_161]
    at org.elasticsearch.xpack.monitoring.exporter.local.LocalBulk.throwExportException(LocalBulk.java:141) ~[?:?]
    at org.elasticsearch.xpack.monitoring.exporter.local.LocalBulk.lambda$doFlush$0(LocalBulk.java:123) ~[?:?]
    at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:60) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.support.ContextPreservingActionListener.onResponse(ContextPreservingActionListener.java:43) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.support.TransportAction$1.onResponse(TransportAction.java:85) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.support.TransportAction$1.onResponse(TransportAction.java:81) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.bulk.TransportBulkAction$BulkRequestModifier.lambda$wrapActionListenerIfNeeded$0(TransportBulkAction.java:571) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:60) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.bulk.TransportBulkAction$BulkOperation$1.finishHim(TransportBulkAction.java:380) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.bulk.TransportBulkAction$BulkOperation$1.onFailure(TransportBulkAction.java:375) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.support.TransportAction$1.onFailure(TransportAction.java:91) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.support.replication.TransportReplicationAction$ReroutePhase.finishAsFailed(TransportReplicationAction.java:909) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.support.replication.TransportReplicationAction$ReroutePhase.handleBlockException(TransportReplicationAction.java:827) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.support.replication.TransportReplicationAction$ReroutePhase.handleBlockExceptions(TransportReplicationAction.java:815) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.support.replication.TransportReplicationAction$ReroutePhase.doRun(TransportReplicationAction.java:713) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.support.replication.TransportReplicationAction.doExecute(TransportReplicationAction.java:170) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.support.replication.TransportReplicationAction.doExecute(TransportReplicationAction.java:98) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:167) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.xpack.security.action.filter.SecurityActionFilter.apply(SecurityActionFilter.java:133) ~[?:?]
    at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:165) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:139) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:81) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.bulk.TransportBulkAction$BulkOperation.doRun(TransportBulkAction.java:350) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.bulk.TransportBulkAction.executeBulk(TransportBulkAction.java:462) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.bulk.TransportBulkAction.doExecute(TransportBulkAction.java:175) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.bulk.TransportBulkAction.lambda$processBulkIndexIngestRequest$4(TransportBulkAction.java:514) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.ingest.PipelineExecutionService$2.doRun(PipelineExecutionService.java:103) [elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:672) [elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-6.2.2.jar:6.2.2]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_161]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_161]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_161]
Caused by: org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];
    at org.elasticsearch.cluster.block.ClusterBlocks.indexBlockedException(ClusterBlocks.java:182) ~[elasticsearch-6.2.2.jar:6.2.2]
    at org.elasticsearch.action.support.replication.TransportReplicationAction$ReroutePhase.handleBlockExceptions(TransportReplicationAction.java:813) ~[elasticsearch-6.2.2.jar:6.2.2]

docker images
REPOSITORY                                      TAG                 IMAGE ID            CREATED             SIZE
<none>                                          <none>              233dc2c81588        14 hours ago        423MB
<none>                                          <none>              0aa94d9613a1        14 hours ago        615MB
oracle/serverjre                                8                   9e58399899c9        14 hours ago        359MB
docker.elastic.co/kibana/kibana                 7.9.2               ba296c26886a        3 days ago          1.18GB
docker.elastic.co/elasticsearch/elasticsearch   7.9.2               caa7a21ca06e        3 days ago          763MB
alpine                                          latest              a24bb4013296        3 months ago        5.57MB
oracle/weblogic                                 12.2.1.4-slim       9f08a7ac6c5a        11 months ago       817MB
<none>                                          <none>              fdf24d1eabc2        11 months ago       1.2GB
12214-weblogic-domain-generic                   latest              93dc22395c42        11 months ago       1.26GB
oracle/weblogic                                 12.2.1.4-generic    b67e91a22473        11 months ago       1.26GB
<none>                                          <none>              ba227fc7cf16        11 months ago       2.99GB
oraclelinux                                     7-slim              874477adb545        13 months ago       118MB
hello-world                                     latest              fce289e99eb9        21 months ago       1.84kB
docker.elastic.co/kibana/kibana                 6.2.2               87fb54648d86        2 years ago         985MB
docker.elastic.co/elasticsearch/elasticsearch   6.2.2               576825ff4f5a        2 years ago         574MB

Sunday, April 26, 2020

AWS Lambda using Python

AWS HOWTO
https://docs.aws.amazon.com/lambda/latest/dg/getting-started.html


AWS repository
https://github.com/awsdocs/aws-lambda-developer-guide


Check prerequisities

[dave@dave ~]$ aws --version

aws-cli/2.0.1 Python/3.7.3 Linux/5.5.16-200.fc31.x86_64 botocore/2.0.0dev5

[dave@dave ~]$ python --version

Python 3.7.6

 



Python Lambda

import json

 
def lambda_handler(event, context):

    # TODO implement

    return {

        'statusCode': 200,

        'body': json.dumps('Hello from Lambda!')

    }



Get lambda in AWS CLI

[dave@dave aws-lambda-developer-guide]$  aws lambda get-function --function-name dave-test-function

{

    "Configuration": {

        "FunctionName": "dave-test-function",

        "FunctionArn": "arn:aws:lambda:eu-central-1:45454545454:function:dave-test-function",

        "Runtime": "python3.8",

        "Role": "arn:aws:iam::45454545:role/dave-lambda-role-test",

        "Handler": "lambda_function.lambda_handler",

        "CodeSize": 299,

        "Description": "",

        "Timeout": 3,

        "MemorySize": 128,

        "LastModified": "2020-04-26T07:53:06.901+0000",

        "CodeSha256": "45454545454545",

        "Version": "$LATEST",

        "TracingConfig": {

            "Mode": "PassThrough"

        },

        "RevisionId": "454545454545",

        "State": "Active",

        "LastUpdateStatus": "Successful"

    },

    "Code": {

        "RepositoryType": "S3",

        "Location": "https://awslambda-eu-cent-1-tasks.s3.eu-central-1.amazonaws.com/snapshots/454534345656/dave-test-function-456544562342423424"

    }

}

 

Thursday, April 9, 2020

Install Oracle WebLogic Server 14.1.1.0.0 on Fedora Linux

Download
https://www.oracle.com/middleware/technologies/fusionmiddleware-downloads.html

Documentation
https://docs.oracle.com/en/middleware/standalone/weblogic-server/14.1.1.0/index.html

Weblogic JDK 11 Certification

Oracle WebLogic Server 14c (14.1.1.0.0) is certified for use with JDK 11.

Supported configurations https://www.oracle.com/middleware/technologies/fusion-certification.html


Oracle JDK 11 download https://www.oracle.com/java/technologies/javase-jdk11-downloads.html

Install Oracle JDK 11 via rpm ( dnf fails on missing dependencies)

[dave@dave Downloads]$ sudo rpm -ivh  jdk-11.0.6_linux-x64_bin.rpm

warning: jdk-11.0.6_linux-x64_bin.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY

Verifying...                          ################################# [100%]

Preparing...                          ################################# [100%]

Updating / installing...

   1:jdk-11.0.6-2000:11.0.6-ga        ################################# [100%]

 

Change Java version for system

sudo alternatives --config java

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.fc31.x86_64/jre/bin/java)
 + 2           /usr/java/jdk1.8.0_231-amd64/jre/bin/java
*  3           /usr/java/jdk-11.0.6/bin/java

Enter to keep the current selection[+], or type selection number: 3


Verify Java version

$ java -version
java version "11.0.6" 2020-01-14 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.6+8-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.6+8-LTS, mixed mode)


Install Weblogic 14.1


$ java -jar fmw_14.1.1.0.0_wls.jar  
Launcher log file is /tmp/OraInstall2020-04-09_10-35-56AM/launcher2020-04-09_10-35-56AM.log. 
Extracting the installer . . . . . Done 
Checking if CPU speed is above 300 MHz.   Actual 2754.936 MHz    Passed 
Checking monitor: must be configured to display at least 256 colors.   Actual 16777216    Passed 
Checking swap space: must be greater than 512 MB.   Actual 8015 MB    Passed 
Checking temp space: must be greater than 300 MB.   Actual 7027 MB    Passed 
Preparing to launch the Oracle Universal Installer from /tmp/OraInstall2020-04-09_10-35-56AM 
 


Start  domain

Starting WLS with line:

/usr/java/jdk-11.0.6/bin/java -server   -Xms256m -Xmx512m -XX:CompileThreshold=8000 -cp /app/weblogic/wlserver/server/lib/weblogic-launcher.jar -Dlaunch.use.env.classpath=true -Dweblogic.Name=AdminServer -Djava.security.policy=/app/weblogic/wlserver/server/lib/weblogic.policy  -Djava.system.class.loader=com.oracle.classloader.weblogic.LaunchClassLoader  -javaagent:/app/weblogic/wlserver/server/lib/debugpatch-agent.jar -da -Dwls.home=/app/weblogic/wlserver/server -Dweblogic.home=/app/weblogic/wlserver/server      weblogic.Server

 

Sunday, April 5, 2020

Fedora - convert DVD

 RPM Fusion


These tools require non-free resource - enable RPM Fusion

https://rpmfusion.org/Configuration/ 

 Install non-free packages for DVD


sudo dnf install rpmfusion-free-release-tainted

sudo dnf install libdvdcss
 Install various packages for sound and video
 

sudo dnf groupupdate multimedia --setop="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin

sudo dnf groupupdate sound-and-video

    Whole DVD backup


    sudo dnf install dvdbackup 
    
    ============================================================================================================================================================ 
     Package                              Architecture                      Version                                     Repository                         Size 
    ============================================================================================================================================================ 
    Installing: 
     dvdbackup                            x86_64                            0.4.2-13.fc31                               fedora                             62 k 



    EXAMPLES
    
           dvdbackup -I
    
                  gathers information about the DVD.  /dev/dvd is the default device tried - you need to use -i if your device name is different.
    
     
           dvdbackup -M
    
                  backups the whole DVD.  This action creates a valid DVD-Video structure that can be burned to a DVD-/+R(W) with help of genisoimage.
    
     
           dvdbackup -F
    
                  backups the main feature of the DVD.  This action creates a valid DVD-Video structure of the feature title set.  Note that this  will  not
    
                  result in an image immediately watchable - you will need another program like dvdauthor to help construct the IFO files.
    
     
                  dvdbackup defaults to get the 16:9 version of the main feature if a 4:3 is also present on the DVD.  To get the 4:3 version use -a 0.
    
     
                  dvdbackup makes it best to make a intelligent guess what is the main feature of the DVD - in case it fails please send a bug report.
    
     

     

     Using VLC

    https://linuxconfig.org/how-to-rip-dvds-with-vlc#h3-how-to-rip-a-dvd-to-your-hard-drive-with-vlc

     Using Handbrake


    https://linuxconfig.org/how-to-convert-video-formats-on-linux


    sudo dnf install handbrake
    
    
    ================================================================================
    
     Package        Arch        Version           Repository                   Size
    
    ================================================================================
    
    Installing:
    
     HandBrake      x86_64      1.3.1-1.fc31      rpmfusion-free-updates      434 kPaste your text here.
    


    sudo dnf install handbrake-gui
    
    
    ================================================================================
    
     Package           Arch       Version          Repository                  Size
    
    ================================================================================
    
    Installing:
    
     HandBrake-gui     x86_64     1.3.1-1.fc31     rpmfusion-free-updates     3.5 M
    


    Subtitle edit
    https://github.com/SubtitleEdit/subtitleedit/releases

    Sunday, March 1, 2020

    Install Python3 on Centos 7

    To avoid impact on Centos own Python 2 packages use Python3  venv

    Install Python3

    $ sudo yum install -y python3
    


    Create venv on Python3

    $ python3 -m venv python3-virtualenv
    
    $ pip3 freeze
    
    $ source python3-virtualenv/bin/activate
    


    $ python
    
    Python 3.6.8 (default, Aug  7 2019, 17:28:10) 
    
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
    
    Type "help", "copyright", "credits" or "license" for more information.
    
    >>> 
    



    On Fedora 31 Python 3 is default


    [dave@localhost ~]$ python3
    
    Python 3.7.6 (default, Jan 30 2020, 09:44:41) 
    
    [GCC 9.2.1 20190827 (Red Hat 9.2.1-1)] on linux
    
    Type "help", "copyright", "credits" or "license" for more information.
    
    >>> 
    
    [dave@localhost ~]$ python2
    
    Python 2.7.17 (default, Oct 20 2019, 00:00:00) 
    
    [GCC 9.2.1 20190827 (Red Hat 9.2.1-1)] on linux2
    
    Type "help", "copyright", "credits" or "license" for more information.
    
    >>> 
    
    [dave@localhost ~]$ python
    
    Python 3.7.6 (default, Jan 30 2020, 09:44:41) 
    
    [GCC 9.2.1 20190827 (Red Hat 9.2.1-1)] on linux
    
    Type "help", "copyright", "credits" or "license" for more information.
    
    >>> 
    
     

    Sunday, February 9, 2020

    MicroK8s - deploy sample app

    MicroK8s quick start guide 



    Get nodes

    [dave@localhost ~]$ microk8s.kubectl get nodes
    
    NAME                    STATUS   ROLES    AGE   VERSION
    
    localhost.localdomain   Ready    <none>   24h   v1.17.2
    
     


    Get services

    [dave@localhost ~]$ microk8s.kubectl get services
    
    NAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE
    
    kubernetes   ClusterIP   10.152.183.1   <none>        443/TCP   24h
    
     


    [dave@localhost ~]$ microk8s.kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1
    
    deployment.apps/kubernetes-bootcamp created
    
     

    [dave@localhost ~]$ microk8s.kubectl get pods
    
    NAME                                   READY   STATUS    RESTARTS   AGE
    
    kubernetes-bootcamp-69fbc6f4cf-f2vvk   1/1     Running   0          41s
    
     

    Get deployments

    [dave@localhost ~]$ kubectl get deployments
    
    NAME                  READY   UP-TO-DATE   AVAILABLE   AGE
    
    kubernetes-bootcamp   1/1     1            1           7m12s
    
     


    Get pod name

    [dave@localhost ~]$ export POD_NAME=$(kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
    
    [dave@localhost ~]$ echo Name of the Pod: $POD_NAME
    
    Name of the Pod: kubernetes-bootcamp-69fbc6f4cf-f2vvk
    
     


    Describe pods
    [dave@localhost ~]$ kubectl describe pods
    
    Name:         kubernetes-bootcamp-69fbc6f4cf-f2vvk
    
    Namespace:    default
    
    Priority:     0
    
    Node:         localhost.localdomain/192.168.0.116
    
    Start Time:   Sun, 09 Feb 2020 08:53:15 +0100
    
    Labels:       app=kubernetes-bootcamp
    
                  pod-template-hash=69fbc6f4cf
    
    Annotations:  <none>
    
    Status:       Running
    
    IP:           10.1.30.34
    
    IPs:
    
      IP:           10.1.30.34
    
    Controlled By:  ReplicaSet/kubernetes-bootcamp-69fbc6f4cf
    
    Containers:
    
      kubernetes-bootcamp:
    
        Container ID:   containerd://e1c171143d299f88fb686f83e2fa2aae1cbe59e14cff53f4f332c2ccc2fb3f2e
    
        Image:          gcr.io/google-samples/kubernetes-bootcamp:v1
    
        Image ID:       gcr.io/google-samples/kubernetes-bootcamp@sha256:0d6b8ee63bb57c5f5b6156f446b3bc3b3c143d233037f3a2f00e279c8fcc64af
    
        Port:           <none>
    
        Host Port:      <none>
    
        State:          Running
    
          Started:      Sun, 09 Feb 2020 08:53:26 +0100
    
        Ready:          True
    
        Restart Count:  0
    
        Environment:    <none>
    
        Mounts:
    
          /var/run/secrets/kubernetes.io/serviceaccount from default-token-msp2q (ro)
    
    Conditions:
    
      Type              Status
    
      Initialized       True 
    
      Ready             True 
    
      ContainersReady   True 
    
      PodScheduled      True 
    
    Volumes:
    
      default-token-msp2q:
    
        Type:        Secret (a volume populated by a Secret)
    
        SecretName:  default-token-msp2q
    
        Optional:    false
    
    QoS Class:       BestEffort
    
    Node-Selectors:  <none>
    
    Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
    
                     node.kubernetes.io/unreachable:NoExecute for 300s
    
    Events:
    
      Type    Reason     Age   From                            Message
    
      ----    ------     ----  ----                            -------
    
      Normal  Scheduled  11m   default-scheduler               Successfully assigned default/kubernetes-bootcamp-69fbc6f4cf-f2vvk to localhost.localdomain
    
      Normal  Pulling    11m   kubelet, localhost.localdomain  Pulling image "gcr.io/google-samples/kubernetes-bootcamp:v1"
    
      Normal  Pulled     11m   kubelet, localhost.localdomain  Successfully pulled image "gcr.io/google-samples/kubernetes-bootcamp:v1"
    
      Normal  Created    11m   kubelet, localhost.localdomain  Created container kubernetes-bootcamp
    
      Normal  Started    11m   kubelet, localhost.localdomain  Started container kubernetes-bootcamp
    
     


    Explore introduction https://kubernetes.io/docs/tutorials/kubernetes-basics/explore/explore-intro/

    Get logs from pod

    [dave@localhost ~]$ kubectl logs $POD_NAME
    
    Kubernetes Bootcamp App Started At: 2020-02-09T07:53:26.300Z | Running On:  kubernetes-bootcamp-69fbc6f4cf-f2vvk 
    
     
     


    Exec commands on pod

    [dave@localhost ~]$ kubectl exec $POD_NAME env
    
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    
    HOSTNAME=kubernetes-bootcamp-69fbc6f4cf-f2vvk
    
    NPM_CONFIG_LOGLEVEL=info
    
    NODE_VERSION=6.3.1
    
    KUBERNETES_PORT=tcp://10.152.183.1:443
    
    KUBERNETES_PORT_443_TCP=tcp://10.152.183.1:443
    
    KUBERNETES_PORT_443_TCP_PROTO=tcp
    
    KUBERNETES_PORT_443_TCP_PORT=443
    
    KUBERNETES_PORT_443_TCP_ADDR=10.152.183.1
    
    KUBERNETES_SERVICE_HOST=10.152.183.1
    
    KUBERNETES_SERVICE_PORT=443
    
    KUBERNETES_SERVICE_PORT_HTTPS=443
    
    HOME=/root
    
     


    Run bash in pod
    [dave@localhost ~]$ kubectl exec -ti $POD_NAME bash
    
    root@kubernetes-bootcamp-69fbc6f4cf-f2vvk:/# cat server.js
    
    var http = require('http');
    
    var requests=0;
    
    var podname= process.env.HOSTNAME;
    
    var startTime;
    
    var host;
    
    var handleRequest = function(request, response) {
    
      response.setHeader('Content-Type', 'text/plain');
    
      response.writeHead(200);
    
      response.write("Hello Kubernetes bootcamp! | Running on: ");
    
      response.write(host);
    
      response.end(" | v=1\n");
    
      console.log("Running On:" ,host, "| Total Requests:", ++requests,"| App Uptime:", (new Date() - startTime)/1000 , "seconds", "| Log Time:",new Date());
    
    }
    
    var www = http.createServer(handleRequest);
    
    www.listen(8080,function () {
    
        startTime = new Date();;
    
        host = process.env.HOSTNAME;
    
        console.log ("Kubernetes Bootcamp App Started At:",startTime, "| Running On: " ,host, "\n" );
    
    });
    
    root@kubernetes-bootcamp-69fbc6f4cf-f2vvk:/# curl localhost:8080
    
    Hello Kubernetes bootcamp! | Running on: kubernetes-bootcamp-69fbc6f4cf-f2vvk | v=1
    
     





    Saturday, February 8, 2020

    Install microk8s on Fedora

    HOWTO

    https://microk8s.io/#get-started


    Install snap

    https://snapcraft.io/docs/installing-snapd

    https://www.cyberciti.biz/faq/install-snapd-on-fedora-linux-system-dnf-command/

    [dave@localhost ~]$ sudo dnf install snapd
    
    Fedora Modular 31 - x86_64 - Updates                                                                         40 kB/s |  23 kB     00:00    
    
    Fedora 31 - x86_64 - Updates                                                                                 27 kB/s |  24 kB     00:00    
    
    Fedora 31 - x86_64 - Updates                                                                                416 kB/s | 421 kB     00:01    
    
    Dependencies resolved.
    
    ============================================================================================================================================
    
     Package                             Architecture                 Version                               Repository                     Size
    
    ============================================================================================================================================
    
    Installing:
    
     snapd                               x86_64                       2.42.2-1.fc31                         updates                        16 M
    
    Installing dependencies:
    
     snap-confine                        x86_64                       2.42.2-1.fc31                         updates                       2.4 M
    
     snapd-selinux                       noarch                       2.42.2-1.fc31                         updates                       220 k
    
     
    Transaction Summary
    
    ============================================================================================================================================
    
    Install  3 Packages
    
     
    Total download size: 18 M
    
    Installed size: 70 M
    
    Is this ok [y/N]: y
    
    Downloading Packages:
    
    (1/3): snapd-selinux-2.42.2-1.fc31.noarch.rpm                                                               912 kB/s | 220 kB     00:00    
    
    (2/3): snap-confine-2.42.2-1.fc31.x86_64.rpm                                                                2.9 MB/s | 2.4 MB     00:00    
    
    (3/3): snapd-2.42.2-1.fc31.x86_64.rpm                                                                       7.9 MB/s |  16 MB     00:02    
    
    --------------------------------------------------------------------------------------------------------------------------------------------
    
    Total                                                                                                       7.3 MB/s |  18 MB     00:02     
    
    Running transaction check
    
    Transaction check succeeded.
    
    Running transaction test
    
    Transaction test succeeded.
    
    Running transaction
    
      Preparing        :                                                                                                                    1/1 
    
      Running scriptlet: snapd-selinux-2.42.2-1.fc31.noarch                                                                                 1/3 
    
      Installing       : snapd-selinux-2.42.2-1.fc31.noarch                                                                                 1/3 
    
      Running scriptlet: snapd-selinux-2.42.2-1.fc31.noarch                                                                                 1/3 
    
      Installing       : snap-confine-2.42.2-1.fc31.x86_64                                                                                  2/3 
    
      Installing       : snapd-2.42.2-1.fc31.x86_64                                                                                         3/3 
    
      Running scriptlet: snapd-2.42.2-1.fc31.x86_64                                                                                         3/3 
    
    Created symlink /etc/systemd/system/sockets.target.wants/snapd.socket → /usr/lib/systemd/system/snapd.socket.
    
    Created symlink /etc/systemd/user/sockets.target.wants/snapd.session-agent.socket → /usr/lib/systemd/user/snapd.session-agent.socket.
    
     
      Running scriptlet: snapd-selinux-2.42.2-1.fc31.noarch                                                                                 3/3 
    
      Running scriptlet: snapd-2.42.2-1.fc31.x86_64                                                                                         3/3 
    
      Verifying        : snap-confine-2.42.2-1.fc31.x86_64                                                                                  1/3 
    
      Verifying        : snapd-2.42.2-1.fc31.x86_64                                                                                         2/3 
    
      Verifying        : snapd-selinux-2.42.2-1.fc31.noarch                                                                                 3/3 
    
     
    Installed:
    
      snap-confine-2.42.2-1.fc31.x86_64               snapd-2.42.2-1.fc31.x86_64               snapd-selinux-2.42.2-1.fc31.noarch              
    
     
    Complete!
    
    [dave@localhost ~]$ sudo ln -s /var/lib/snapd/snap /snap
    
    [dave@localhost ~]$ ls -l /snap
    
    lrwxrwxrwx. 1 root root 19 Feb  8 07:46 /snap -> /var/lib/snapd/snap
    
    [dave@localhost ~]$ snap version
    
    snap    2.42.2-1.fc31
    
    snapd   unavailable
    
    series  -
    
     


    Start snap service

    [dave@localhost ~]$ snap search vlc
    
    error: cannot list snaps: cannot communicate with server: Get http://localhost/v2/find?q=vlc&scope=wide: dial unix /run/snapd.socket: connect: no such file or directory
    
    [dave@localhost ~]$ sudo systemctl start snapd.service
    
    [dave@localhost ~]$ snap search vlc
    
    Name            Version                 Publisher  Notes  Summary
    
    vlc             3.0.8                   videolan✓  -      The ultimate media player
    
    mjpg-streamer   2.0                     ogra       -      UVC webcam streaming tool
    
    audio-recorder  3.0.5+rev1432+pkg-7b07  brlin      -      A free audio-recorder for Linux (EXTREMELY BUGGY)
    
    dav1d           0.5.1-20-g52c7427       videolan✓  -      AV1 decoder from VideoLAN
    
    peerflix        v0.39.0+git1.df28e20    pmagill    -      Streaming torrent client for Node.js
    
    [dave@localhost ~]$ snap search microk8s
    
    Name      Version  Publisher   Notes    Summary
    
    microk8s  v1.17.2  canonical✓  classic  Kubernetes for workstations and appliances
    
     


    Install microk8s


    [dave@localhost ~]$ sudo snap install microk8s --classic
    
    2020-02-08T07:51:58+01:00 INFO Waiting for restart...
    
    Warning: /var/lib/snapd/snap/bin was not found in your $PATH. If you've not restarted your session
    
             since you installed snapd, try doing that. Please see https://forum.snapcraft.io/t/9469
    
             for more details.
    
     
    microk8s v1.17.2 from Canonical✓ installed
    
     


    List services

    [dave@localhost ~]$ snap list
    
    Name      Version    Rev   Tracking  Publisher   Notes
    
    core      16-2.42.5  8268  stable    canonical✓  core
    
    microk8s  v1.17.2    1173  stable    canonical✓  classic
    
    [dave@localhost ~]$ snap services 
    
    Service                             Startup  Current  Notes
    
    microk8s.daemon-apiserver           enabled  active   -
    
    microk8s.daemon-apiserver-kicker    enabled  active   -
    
    microk8s.daemon-cluster-agent       enabled  active   -
    
    microk8s.daemon-containerd          enabled  active   -
    
    microk8s.daemon-controller-manager  enabled  active   -
    
    microk8s.daemon-etcd                enabled  active   -
    
    microk8s.daemon-flanneld            enabled  active   -
    
    microk8s.daemon-kubelet             enabled  active   -
    
    microk8s.daemon-proxy               enabled  active   -
    
    microk8s.daemon-scheduler           enabled  active   -
    
     


    Add /snap/bin into secure path into sudo

    [root@localhost ~]# visudo
    
    [root@localhost ~]# grep snap  /etc/sudoers
    
    Defaults    secure_path = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
    
     


    [dave@localhost ~]$ sudo microk8s.status --wait-ready
    
    [sudo] password for dave: 
    
    microk8s is running
    
    addons:
    
    cilium: disabled
    
    dashboard: disabled
    
    dns: disabled
    
    fluentd: disabled
    
    gpu: disabled
    
    helm3: disabled
    
    helm: disabled
    
    ingress: disabled
    
    istio: disabled
    
    jaeger: disabled
    
    juju: disabled
    
    knative: disabled
    
    kubeflow: disabled
    
    linkerd: disabled
    
    metallb: disabled
    
    metrics-server: disabled
    
    prometheus: disabled
    
    rbac: disabled
    
    registry: disabled
    
    storage: disabled
    
     


    Turn on standard services


    [dave@localhost ~]$ sudo microk8s.enable dns dashboard registry
    
    Enabling DNS
    
    Applying manifest
    
    serviceaccount/coredns created
    
    configmap/coredns created
    
    deployment.apps/coredns created
    
    service/kube-dns created
    
    clusterrole.rbac.authorization.k8s.io/coredns created
    
    clusterrolebinding.rbac.authorization.k8s.io/coredns created
    
    Restarting kubelet
    
    DNS is enabled
    
    Applying manifest
    
    serviceaccount/kubernetes-dashboard created
    
    service/kubernetes-dashboard created
    
    secret/kubernetes-dashboard-certs created
    
    secret/kubernetes-dashboard-csrf created
    
    secret/kubernetes-dashboard-key-holder created
    
    configmap/kubernetes-dashboard-settings created
    
    role.rbac.authorization.k8s.io/kubernetes-dashboard created
    
    clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created
    
    rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
    
    clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
    
    deployment.apps/kubernetes-dashboard created
    
    service/dashboard-metrics-scraper created
    
    deployment.apps/dashboard-metrics-scraper created
    
    service/monitoring-grafana created
    
    service/monitoring-influxdb created
    
    service/heapster created
    
    deployment.apps/monitoring-influxdb-grafana-v4 created
    
    serviceaccount/heapster created
    
    clusterrolebinding.rbac.authorization.k8s.io/heapster created
    
    configmap/heapster-config created
    
    configmap/eventer-config created
    
    deployment.apps/heapster-v1.5.2 created
    
     
    If RBAC is not enabled access the dashboard using the default token retrieved with:
    
     
    token=$(microk8s.kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)
    
    microk8s.kubectl -n kube-system describe secret $token
    
     
    In an RBAC enabled setup (microk8s.enable RBAC) you need to create a user with restricted
    
    permissions as shown in:
    
    https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md
    
     
    Enabling the private registry
    
    Enabling default storage class
    
    deployment.apps/hostpath-provisioner created
    
    storageclass.storage.k8s.io/microk8s-hostpath created
    
    serviceaccount/microk8s-hostpath created
    
    clusterrole.rbac.authorization.k8s.io/microk8s-hostpath created
    
    clusterrolebinding.rbac.authorization.k8s.io/microk8s-hostpath created
    
    Storage will be available soon
    
    Applying registry manifest
    
    namespace/container-registry created
    
    persistentvolumeclaim/registry-claim created
    
    deployment.apps/registry created
    
    service/registry created
    
    The registry is enabled
    
     


    List services

    [dave@localhost ~]$ microk8s.enable --help
    
    Usage: microk8s.enable ADDON...
    
    Enable one or more ADDON included with microk8s
    
    Example: microk8s.enable dns storage
    
     
    Available addons:
    
     
      cilium
    
      dashboard
    
      dns
    
      fluentd
    
      gpu
    
      helm
    
      helm3
    
      ingress
    
      istio
    
      jaeger
    
      juju
    
      knative
    
      kubeflow
    
      linkerd
    
      metallb
    
      metrics-server
    
      prometheus
    
      rbac
    
      registry
    
      storage
    
     

    Add user into microk8s group

    [dave@localhost ~]$ microk8s.status --wait-ready
    
    Insufficient permissions to access MicroK8s.
    
    You can either try again with sudo or add the user dave to the 'microk8s' group:
    
     
        sudo usermod -a -G microk8s dave
    
     
    The new group will be available on the user's next login.